i am new to activemq. i read some article and doing this.please help me to solve the following task. i produce one message to activemq from my java application and i have a consumer for that message in another java application.so i will get the message from activemq. every time this consumer(listener) looking for the message in activemq. my question is activemq can push the message to consumer(listener).
activemq only for storing the message ? it will do any push or pull operation ? activemq always need producer(produce the message) and consumer(consume the message) ?
can anyone help me
thanks
ActiveMq, WebLogic, IBM MQ, and any JMS compatible provider are destination-based messaging systems; the destination, or subject, is a queue or topic. When sending a message, producer can send the message and disconnect immediately; ActiveMq will store message on queue. When receiving, message consumer can receive sync or async, independent of sender.
Message producer sends message to destination; it's job is done.
QueueSender queueSender = queueSession.createSender(myQueue);
queueSender.send(message);
Message consumer can receive message one of two ways:
Synchrounous, here you call receive()
explicitly
QueueReceiver queueReceiver = queueSession.createReceiver(myQueue);
queueConnection.start();
Message m = queueReceiver.receive();
Asynchronous, here you implement callback method from MessageListener
interface:
class MyQueueReceiver implements javax.jms.MessageListener {
QueueReceiver queueReceiver = queueSession.createReceiver(myQueue);
queueReceiver.setMessageListener(this);
...
public void onMessage(Message msg){
//consume message here
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With