Topics
photos
biographics
letterpress
pike
hyperlinks, etc
projects
contact info
Recently Changed
Recent Albums
Basement
rephotograph
Monotype molds
Baltimore 2015
Europe 2014
Interesting People
James
JZ
Deff
Bertrand
Powered by FinScribe
Enabling message receipt and processing
1. enable Stomp support for your Message Broker (see
http://stomp.codehaus.org for more details.)
2. install Public.Protocols.Stomp from monger.
pike -x monger --install Public.Protocols.Stomp
3. add the following to your application configuration file:
[processors] class=my_stomp_processor[stomp] broker=stomp://user:pass@host:port
4. create a class, my_stomp_processor (as mentioned in the configuration file above) that inherits Fins.StompProcessor, saved in the classes directory of your application.
inherit Fins.StompProcessor;
5. create a controller class that inherits Fins.StompController and overrides the constant subscribes_to. The constant subscribes_to should be a STOMP messaging destination. This example code might be called classes/my_stomp_controller.pike:
inherit Fins.StompController;constant subscribes_to = "/queue/my_queue";
6. mount that new StompController class within your controller tree, just as you would with any other controller. its location doesn't matter, and it makes sense to mark it static. For example, from your controller.pike:
inherit Fins.FinsController;
Fins.Controller my_stomp_controller;
void start() { my_stomp_controller = load_controller("my_stomp_controller"); }
7. implement on_message() in your Stomp controller. For example, in our my_stomp_controller.pike described above:
inherit Fins.StompController;constant subscribes_to = "/queue/my_queue";
void on_message(Fins.StompRequest request) { // handle the message here. werror("Headers: %On", request->headers); werror("Body: %On", request->body); }
Enabling message publishing
1. Publishing requires the StompProcessor to be enabled for your application, so if you only want to send messages, you don't need to define a StompController (steps 5-7) above.
2. Messaging works from any class derived from Fins.FinsBase, which is any Controller, the View or Model.
3. Inherit Fins.StompMessenger in the class you want to be able to send messages from.
4. To send a message, you can use the publish() method provided in Fins.StompMessenger.
inherit Fins.StompController; inherit Fins.StompMessenger;constant subscribes_to = "/queue/my_queue";
void on_message(Fins.StompRequest request) { // handle the message here. werror("Headers: %On", request->headers); werror("Body: %On", request->body); // publish() is provided by StompMessenger. publish("/topics/my_topic", "thanks for the message.", (["header1": "somevalue"])); }
Not categorized | RSS Feed | BackLinks