I have a requirement where I have to copy value of MessageID, correlationID, persistence, Expiry and Priority from request MQ message to response. I put the request message in the queue using RFHUtil . but as the message is consumed by the Session beans the messageID of MQMD header changes to some different value -HEXADECIMAL, which is different from the MessageID I put in RFHUTIL.
then I copy the above values from request to response message using set methods,- setJMSMessageID etc. but the values are different once I view the response message.
is this due to MQ to JMS conversion? what can be the solution to this.
Earlier I was using MQ Message and was able to copy all fields from request to response.
MessageID in IBM MQ is always hexadecimal, no matter from which API it is set, Base MQ or MQ JMS.
You don't need to set the MessageID while sending the request message. Let MQ do that for you. MQ will generate a unique message id for the request message. In your session beans, you simply copy the MessageID of the request message to CorrelationID of response message. This way you can correlate request and response messages.
See IBM WebSphere MQ request/reply scenario for more details.
UPDATE
Any value set using setMessageID method is ignored when the message is sent, but the method can be used to change the value in a received message.
As the message ID set by setMessageID method is ignored when a message is sent, an application cannot specify the message ID of an outgoing message. As a consequence, an application cannot receive a message and then forward the same message, or send a different message, with the same message ID as that of the message it has received. See the link:
Related
I have a stomp application and I set the ack mode to client during subscription from front-end. During the subscription the same client during a session would connect to the same queue in the message broker ActiveMQ Artemis because a session id is used for queue.But a different id is passed in the header every time the user reloads the page.
The subscription code is shown below.
consumer.subscribe(
'/queue.'+ rscSessionId,
function (response) {
console.log("resposne");
},
{
"subscription-type": "ANYCAST",
ack: "client",
id: generateId(),
}
);
Once I send message from client it gets send to frontend with following headers.
MESSAGE
subscription:1234
message-id:1543449
destination:/queue.sessionid
expires:1653914606725
redelivered:false
priority:4
persistent:true
timestamp:1653912806717
destination-type:ANYCAST
__AMQ_CID:30e64793-dd9b-11ec-8843-c238460c3152
_type:ResponseData
content-length:300
and afterwards on every reload.
MESSAGE
subscription:1235
message-id:1543449
destination:/queue.sessionid
expires:1653914606725
redelivered:true
priority:4
persistent:true
timestamp:1653912806717
destination-type:ANYCAST
__AMQ_CID:30e64793-dd9b-11ec-8843-c238460c3152
_type:ResponseData
content-length:300
You can see that redelivered is set to true after first delivery and after that every response has redelivered to false. the subscription value keeps getting changed though because of the id passed in header.
How can I make it deliver only once but with guarantee?
Are you actually acknowledging the message once you receive it? If you don't acknowledge the message then once the client closes the connection and subscribes again it will receive the same message again. The different value you're seeing for the subscription header indicates this is what is happening.
To be clear, if you're using the client acknowledgement mode then once you receive the MESSAGE frame you need to send a corresponding ACK frame in order to acknowledge the message. Your client should have a way to do this since it is a standard part of the STOMP specification.
I guess that Artemis is configured with publisher/subscriber messaging style. In this case, every new consumer/receiver/client will get the messages aka you write/read from a topic.
Changing to a point-to-point message style would fix the issue (would only be read once) aka a queue.
This is usually decided by the setup but I recall that ActiveMQ allowed producer to create those on the fly.
If you do need a topic, then you will have to handle the IDs on the client side.
I have an application which uses IBM MQ to send out the request in a queue manager to a particular system B.
The response corresponding to that request is then received back from system B by the application in a sync call and then further business processing happens.
Since we are working on the offshore region, we do not actually send out the request to system B but rather capture it ourselves using the MQJExplorer tool and send back the response, which kind of simulates the prod. behaviour.
The problem here is, or i would say, the overhead is that we have to manually open the mqjexplorer tool, check the request, take a particular attribute from the request(lets say ID), and send back ID+1 so that the application recognizes the response is for ID-1 request.
I would like to know if this particular thing can be automated, with some other tool, where i can define like whenever any such kind of request is received in for eg: MQ001 queue manager and its REQ queue, just extract the ID attribute, do a ID+1 and send back the response in RESP queue of same qm.
There are a pair of IBM supplied samples that come with IBM MQ:-
amqsreq0.c - Sample C program that puts request messages to a message queue and shows the replies (example using REPLY queue)
amqsecha.c - Sample C program - echo messages to reply to queue
They are supplied to allow you to try out a request/reply application.
You already have the equivalent app to do the job that amqsreq0.c does, and you could adapt amqsecha.c to extract your ID attribute, increment it, and then the sample already has the code to send the reply back.
It can be automated by running as a triggered application too.
If 'C' language is not your thing and prefer Java then have a read of a blog posting I did in 2017. It is a complete request/reply scenario with 2 applications: BEServer01.java and RQClient01.java
You can modify BEServer01.java to your liking (and remove the SQL code). BEServer01.java contains all of the code for getting a request message and sending a reply message. Simply replace the variable 'replyText' contents with the reply message that you want.
If you are not a programmer then there is another option but it does not modify the message contents. MQ Visual Edit has a component called: SIM Server. Its purpose is to simulate a server-side component. You configure what 'request' queue to get the messages from and what the reply message text will be. When a messages lands on the request queue, the SIM Server will retrieve it and send the reply message to the queue & queue manager specified in the MQMD's ReplyToQueueName and ReplyToQueueManagerName fields.
I have to send XML message to my jms proxy service (service receive and send back message over JMS) with ESB Task (scheduler).
I tried 2 solutions.
1 solution
In added task I fill:
message -> my XML
injectTo -> set 'proxy'
proxyName -> my proxy name
The result is that, my jms proxy receive the message but without JMS_Corelation (I guess the message is send local in ESB) and I get that error:
Unexpected error sending message back
org.apache.axis2.AxisFault: Transport out has not been set
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:432)
at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:163)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:321)
at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:94)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:255)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:556)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:198)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:488)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:170)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.axis2.transport.local.LocalResponder.handleResponse(LocalResponder.java:214)
at org.apache.axis2.transport.local.LocalResponder.invoke(LocalResponder.java:111)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:163)
at org.apache.synapse.mediators.builtin.RespondMediator.mediate(RespondMediator.java:23)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:255)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:556)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:198)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:488)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:170)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
If I send this message to queue, all workflow works fine, so it is well configure.
2 solution
In added task I fill:
message -> my XML
to -> my jms endpoint
format -> message format
The result is that, there is no result becasue nothing is happend. My jms proxy service doesn't receive any message.
Someone knows how to fix that?
Maybe there is another way to do that?
Your JMS Proxy is configured to receive messages from a JMS queue or topic.
You should try to write a named sequence that send an appropriate message into your queue or topic. Then, configure your scheduled task to call this sequence :
injectTo = sequence
format = soap11 (for exemple)
soapAction = mySoapAction (if needed)
message = <root>myMessage</root>
sequenceName = YourSequenceThatSendTheMessageToJMS
I have create an API in WSO2 ESB that receives JSON messages. I have created a messagestore to store these messages in Message Broker (guaranteed delivery pattern).
Now, the message processor that must read the queue and send the message to the backend REST api, gives the error:
TID: [0] [ESB] [2014-11-21 14:28:46,752] ERROR {org.apache.synapse.message.senders.blocking.BlockingMsgSender} - Error sending Message to url : http://lnx17.redora.local:28080/MZK-DataServices/ProcessJson/cases/newCase {org.apache.synapse.message.senders.blocking.BlockingMsgSender}
org.apache.axis2.AxisFault: Payload could not be written as JSON.
The endpoint is currently defined as an address endpoint with JSON type. I have also tried a HTTP endpoint.
In Message Broker, I cannot see the message, because it is stored as an Object (?)
Any suggestions?
Before sending it to the message store, remove the REST_URL_POSTFIX using a property mediator:
<property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
Then the message will correctly be transferred.
I want to setJMSMessageID in sequence 1,2,3.... while sending a JMS Message in HornetQ. But whenever I tried to set my customized MessageID to JMS message, at the consumer end the MessageID of the same JMS message is different.
While doing so I found that JMS MessageID has some specific format. So how do I set my customized MessageID?
According to the API docs,
http://docs.oracle.com/javaee/5/api/javax/jms/Message.html#setJMSMessageID%28java.lang.String%29
JMS providers set the messageID field when a message is sent.
You cannot override the messageID set by the JMS provider with your own JMSMessageID before the message is sent. Is there a particular reason why you want to set your own message ID?
if you are looking to monitor a sequence, maybe you can consider storing such information inside the content of the message itself, or as a message property.
I am using setJMSCorrelationID for setting custom ID. ON the receiver end, you can use getJMSCorrelationID to retrieve the same..