I use ReplyingKafkaTemplate to send a request to Kafka and receive the reply.
Consumer of the request is a C++ program. After processing the request, its reply is produced by the C++ application. Now my problem is about format of the reply, because it seems that consumer of the reply in spring-side uses correlation Id to find corresponding reply.
Can somebody help me about this problem?
You need to echo back the correlationId header so the template knows which request this reply is for. Simply set the header on the reply in your C++ code to the value of the incoming request header.
Related
is it possible to define how the verification code will be sent when calling the LoginUserIfNeeded method? I need to send it via SMS and not to the application.
Telegram servers decide by themselves through which method to send the code initially.
However if the user did not receive the code (eventually after a given timeout), he can request the code to be sent through an alternative method:
In WTelegramClient, this is done by returning an empty string for "verification_code" (typically, only on the first try)
You should probably first check through which medium Telegram sent the code:
The client.OnUpdate event receives a Auth_SentCode object specifying details (type) about the transmitted verification code. Then you can decide to reply the empty string only if it was transmitted through a medium you don't have access to.
You can check via the Auth_SentCode.next_type field which method will be used to send the code on the next try. (and you can possibly reply an empty verification_code again to try yet another method)
Additionally, on the call to LoginUserIfNeeded you can pass a CodeSettings instance which offer some limited options about the enabled methods for sending of the code.
Here is what I need to accomplish:
Get some messages in System 1 using a Pull Subscription.
Send each message along with acknowledgement id to System 2
Send acknowledgement to the subscription from that System 2.
So, basically I will create a new Pubsub client and send acknowledgement. How can I make this request?
To complement your answer, I just realized that your client is a Pubsub java class and the method execute() belongs to an instance of Acknowledge.
I found a full example that pulls messages from Pubsub. In fact, the pullMessages() method in such example has the sentence you mentioned. Digging into the java framework, this link mentions how the method exetute() is used.
I added the execute() method to the acknowledgment operation:
client.projects().subscriptions()
.acknowledge(getFullSubscriptionsName(config), acknowledgeRequest)
.execute();
The method execute() was not being invoked.
I have a webservice (Restful) that send a message through ActiveMQ, and synchronously receive the response by creating a temporary listener in the same request.
The problem is, the listener wait for response of synchronous process , but never die. I need that listener receive response, and immediately stop the listener once is responded the request of webservice.
I have a great problem, because for each request of web services, a listener is created and this is active, producing overhead.
That code in the link is not production grade - simply an example how to make a "hello world" request reply.
Here is some psuedo code to deal with consuming responses blocking - and closing the consumer afterwards.
MessageConsumer responseConsumer = session.createConsumer(tempDest);
Messages response = responseConsumer.receive(waitTimeout);
// TODO handle msg
responseConsumer.close();
Temp destinations in JMS are pretty slow anyways. You can instead use JMSCorrelationID and make the replies go to a "regular queue" handled by a single consumer for all replies. That way, you need some thread handling code to hand over the message to the web service thread, but it will be non blocking and very fast.
i have wrote a Text Message Sender Program via JMS with C++ following.
tibems_status status = TIBEMS_OK;
status = tibemsMsgProducer_SendToDestination(
m_tProducer,
m_tDestination,
m_tMsg );
Suppose status == 0, this means only that Function has worked succesfull. It doesn't mean that my Text Message was sent succesfull
How can I ensure that my Message was sent succesfull? Should I get a ID or Acknowledge from JMS Queue back?
It depends on the Message Delivery Mode.
When a PERSISTENT message is sent, the tibemsMsgProducer_SendToDestination call will wait for the EMS server to reply with a confirmation.
When a NON_PERSISTENT message is sent, the tibemsMsgProducer_SendToDestination call may or may not wait for a confirmation depending on if authorization is enabled and the npsend_check_mode setting. See the EMS docs (linked above) for specific details.
Lastly, when a RELIABLE_DELIVERY message is sent, the tibemsMsgProducer_SendToDestination call does not wait for a confirmation and will only fail if the connection to the EMS server is lost.
However, even in the situations where a confirmation is sent, this is only confirmation that the EMS server has received the message. It does not confirm that the message was received and processed by the message consumer. EMS Monitoring Messages can be used to determine if the message was acknowledged by the consumer.
The message monitoring topics are in the form $sys.monitor.<D>.<E>.<destination>, where <D> matches Q|q|T|t, <E> matches s|r|a|p|\* and <destination> is the name of the destination. For instance to monitor for message acknowledgment for the queue named beterman, your program would subscribe to $sys.monitor.q.a.beterman (or $sys.monitor.Q.a.beterman if you want a copy of the message that was acknowledged).
The monitoring messages contain many properties, including the msg_id, source_name and target_name. You can use that information to correlate it back to the message you sent.
Otherwise, the simpler option is to use a tibemsMsgRequestor instead of a tibemsMsgProducer. tibemsMsgRequestor_Request will send the message and wait for a reply from the recipient. In this case you are best to use RELIABLE_DELIVERY and NO_ACKNOWLEDGE to remove all the confirmation and acknowledgement messages between the producer and the EMS server and the EMS server and the consumer.
However, if you do go down the tibemsMsgRequestor route, then you may also want to consider simply using a HTTP request instead, with a load balancer in place of the EMS server. Architecturally there isn't much difference between the two options (EMS uses persistent TCP connections, HTTP doesn't)
Producer -> EMS Server -> ConsumerA
-> ConsumerB
Client -> Load Balancer -> ServerA
-> ServerB
But with HTTP you have clear semantics for each of the methods. GET is safe (does not change state), PUT and DELETE are idempotent (multiple identical requests should have the same effect as a single request), and POST is non-idempotent (it causes a change in server state each time it is performed), etc. You also have well defined status codes. If you're using tibemsMsgRequestor you'll need to create bespoke semantics and response status, which will require extra effort to create, maintain and to train the other developers in your team on.
Also, it far easier to find developers with HTTP skills than EMS skills and it's far easier to find information HTTP that EMS, so the tibemsMsgRequestor option will make recruiting more difficult and problem solving issues more difficult.
Because of this HTTP is a better option IMO, for request-reply or for when you want to ensure that that the message sent was processed successfully.
I need to develop an application which will read messages from MSMQ asynchronously. I found good examples of this the official one being
http://msdn.microsoft.com/en-us/library/windows/desktop/ms701332(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ms701349(v=vs.85).aspx
But the additional requirement is MSMQ should keep the message in message queue until I send acknowledgement message. Is there a way to do that? If yes, is there a example out there which demonstrates this?
One more advanced requirement also is that there might be more than one receiver of the same message (or subscriber of the same message queue) and I want MSMQ to delete the message only after all of the subscribers have read the message. Is that possible?
Thanks in advance,
-Neel.