Product/components used and version/fix level:
Integration Server 10.11 and 10.15
Detailed explanation of the problem:
I’m playing with RabbitMQ (surely many of you have already payed with it). however, when it comes to the subcribing a queue, comes a tricky part: when a message arrives, it triggers a callback (a DeliverCallback
), which can be customized to INVOKE a service published in Integration Server.
However, just calling Service.doInvoke(serviceCName, session, inputIData);
is not enough, seems having to create all the “context”.
The Kellton’s blog (How to Integrate RabbitMQ with webMethods? | kellton) and Java Service → ext Java library (rabbit MQ client library → Service.doInvoke fails both shed a light on this subject - but I had no luck making it work.
Here is the portion of the code built so far:
...
DeliverCallback deliverCallback = (consumerTag, delivery) -> {
String properties = delivery.getProperties().getHeaders().toString();
String message = new String(delivery.getBody(), "UTF-8");
com.wm.app.b2b.server.User user = com.wm.app.b2b.server.UserManager.getUser(username);
Session session = StateManager.createContext(0x7fffffffL, "system", user);
session.setUser(user);
session.clearModified();
IData inputIData = IDataFactory.create();
...
cursor.destroy();
try {
Service.doInvoke(triggerService, session, inputIData);
} catch (Exception e) {
e.printStackTrace();
}
StateManager.deleteContext(session.getSessionID());
};
channel.basicConsume(queueName, true, deliverCallback, consumerTag -> { });
...
…and also merged
InvokeState is = new InvokeState();
session = Service.getSession();
User olduser = session.getUser();
InvokeState.setCurrentSession(session);
InvokeState.setSessionUser(olduser);
output = Service.doInvoke(nsServiceName, is.getSession(), input);
I’ve made several tests, and here are what I’ve found so far:
- the messages are being drained - the
autoAck
is set totrue
(refer toChannel.basicConsume()
) and on the “Queue and streams” page (see management plugin) number of “messages ready” and “messages total” inements as new messages are published; - but the “trigger service” is not actually invoked; even if the trigger service is the
pub.flow:debugLog
nothing gets logger in theserver.log
; - I’ve used a sample JavaApp as subscriber using almost the same code, and it shows messages flowing through.
Therefore, what else I’m missing [in order to be able to invoke a service from the callback]?
Error messages / full error message screenshot / log file:
Actually, there is no error message at all.