Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send Message to particular Receiver using JMS Queue

Is it possible to send message to particular receiver using JMS Queue(HornetQ)?

Among so many receivers, I want certain message to be received by receiver which are running on Linux OS.

Every suggestion is appriciated.

Thanks.

like image 825
SmartSolution Avatar asked Jun 03 '11 07:06

SmartSolution


People also ask

How do I receive messages from JMS queue?

You can use the Message Selector field on the Advanced tab to retrieve a specific queue message from the queue. The General tab has the following fields. Literal Value/Process Property/Module Property? The name to be displayed as the label for the activity in the process.

Which of the following method is used to send a message in JMS?

To send a message, an application uses the send() method of a MessageProducer object, as shown in the following example: producer. send(outMessage); An application can use the send() method to send messages in either messaging domain.


1 Answers

You can set a message property using Message.setObjectProperty(String, Object) and then have your consumers select the messages they are interested in using Session.createConsumer(Destination, String)

Sender example:

Message message = session.createMessage();
message.setObjectProperty("OS", "LINUX");
producer.send(message);

Receiver example:

MessageConsumer consumer = session.createConsumer(destination, "OS = 'LINUX'");
//Use consumer to receive messages.

The receiver in the example will ignore (they will go to some other receiver) all messages that do not match the selector. In this case all message where the 'OS' property is not 'LINUX' will be ignored by this consumer.

like image 190
Dev Avatar answered Oct 12 '22 11:10

Dev