I want a Java class (jms receiver) which always run in background and check for any message arrive in jms queue.How it can be possible? Please help.
What you want is a JMS MessageListener. Create your JMS client resources (e.g. connection/context, session, etc.) like normal and then invoke setMessageListener on your consumer passing in your implementation of the MessageListener interface. This is pretty basic JMS stuff so you can find more detailed tutorials online.
Related
I am creating a message bus jar which connects to different MQ broker like Rabbit MQ. The jar will be used by many applications to send and receive message from Rabbit.
While sending message is working as expected from my application, not clear about how to design the listener. Obviously the #RabbitListener is in the jar but I want the message should reach the class in applications.
Any suggestions appreciated.
Is there any better way to create a kind of bus library for rabbit spring and use in applications.
Sounds like you need to make yourself familiar with https://spring.io/projects/spring-integration. And also take a look, please, into this project which already implements something similar: https://spring.io/projects/spring-cloud-bus
What are we doing?
We are using mq-jms-spring-boot-starter and #JMSListener-annotation to implement an Message-Listener for a IBM MQ queue (lets call this: QueueA).
When an exception is thrown within the function annotated with #JMSListener the current message is automatically re-queued in the connected QueueA. At the MQ-Server we configured a retry-count (3 retries) and after 3 un-successful retries the message is send to a backout-queue (QueueA-BACKOUT).
What's our question?
Basically we want to use the automatic mechanism provided by #JMSListener to re-queue a message but with a delay before doing so.
For testing purposes we use ActiveMQ. There we could easily configure an initialRedeliveryDelay/redeliveryDelay in the ConnectionFactory.
What is the equivalent way to configure something like this for IBM MQ (using the mentioned Spring Starter)?
(INFO: we did not implement an errorhandler for the listener yet, might this be the right place to do something like this? Or is there a simple configuration-style option to solve this?)
//OVERVIEW//
I have a Java Swing Client that is pushing messages to a broker. For the producer, I am using the Spring SingleConnectionFactory:
org.springframework.jms.connection.SingleConnectionFactory
that is wrapped around an ActiveMQConnectionFactory:
org.apache.activemq.ActiveMQConnectionFactory
I am using the Spring JMSTemplate:
org.springframework.jms.core.JmsTemplate
to provide the mechanisms to send messages from the producer to the broker.
// PROBLEM //
Sometimes, the broker might go down, or the network might fail. When this happens, the only way I have been able to re-establish connection to the broker is to re-start the Swing application (producer) to re-initialize the components mentioned above.
Does anyone know how this might be done at run-time? Atempting to re-initialise beans at runtime sounds like a hack and I was wondering if there was a more elegant configuration option.
Thanks
I am new to Tibco, ActiveMatrix BusinessWorks and Tibco Designer.
I followed the Tutorial of Jazon Samillano regarding sending and receiving JMS Messages. In this tutorial he sends a Text within the JMS Body to the Queue.
What I am now trying is to send a Java-Object via another Java-Application to the Queue and read the Java-Object within Tibco Designer with the Palette-Element JMS Queue Receiver. After that I want to process the data and then send a JMS Message to another Queue with the same Object (with some slight manipulations) via a JMS Queue Sender.
In the configuration of the JMS Queue Receiver and of the JMS Queue Sender there is a Dropdown List where I can chose the Message Type "Object". But what do I have to do then. I think I need to make a mapping between the JMS Body to a variable (= the reprasentation of the Java Object in Tibco Designer) to process the data. But how can I do this?
Does anyone knows a good tutorial or can anyone explain how I can do this?
I would really really appreciate your help.
Thanks in advance
What you have received is serialized java objects via JMS. You can use the Java Palettes Activity to deserialize it and do whatever you want to do with that object. If your serialized object not from standard Java class (e.g. String) then you need to have the java class or jar in the class path of designer.
I am creating a grails web app which makes use of JMS messaging. I have installed the JMS plugin for grails and using activemq as the messaging provider. I want to implement a request/response pattern in grails.
I was successfully able to send a message to the queue using the
sendQueueJMSMessage("queueName",Map message) from a controller.
I then created a service which contains the onMessage() method that listens to the "queueName" as stated above.
The onMessage() method does some processing and successfully sends an email to the user.
The above scenario has been implemented successfully.
Now, I would like to receive a response from this onMessage() method.
Lets say I want to implement the below scenario.
The request is added to the queue and waits for a response. I looked around but I couldnt find any help.
Please give me a lead on this. I really appreciate it.
Spring JMS adds support for auto replies, which the Grails plugin supports. See: http://gpc.github.com/grails-jms/docs/manual/guide/5.%20Receiving%20Messages.html#5.3%20Listener%20Return%20Values
Here is a test exercising this stuff: https://github.com/gpc/grails-jms/blob/master/test/integration/grails/plugin/jms/test/reply/ReplyingListenerServiceSpec.groovy#L12
The other option is to just send another message from your first message receiving method.
you did not provide much to work with here so the my suggestion is to take a look at the samples in the Grails JMS Plugin - Reference Documentation: 5. Receiving Messages, or provide some code