Update:
Now, a “better answer” than the one before, that answers the original question: how to INVOKE Integration Service services from “outside of a service context”, but still from the same JVM (really doInvoke()
, not doThreadInvoke()
).
Jumping straight to the core code:
public static final void subscribeQueue_Consumer_doInvoke(IData pipeline) throws ServiceException {
...
try {
connection = __borrowConnection(alias);
Channel channel = connection.createChannel();
channel.basicQos(prefetchCount);
consumerTag = channel.basicConsume(queueName, autoAck, new DefaultConsumer(channel) {
private final String RABBITMQ_CALLBACK_WRAPPER_SERVICE = "SampleRoot.services.subscriber.internal:";
@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties,
byte[] body) throws IOException {
try {
com.wm.lang.ns.NSName nsService = NSName.create(RABBITMQ_CALLBACK_WRAPPER_SERVICE);
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();
/* */ InvokeState is = new InvokeState();
/* */ InvokeState.setCurrentSession(session);
/* */ InvokeState.setSessionUser(user);
IData inputIData = IDataFactory.create();
...
Service.doInvoke(triggerService, session, inputIData);
StateManager.deleteContext(session.getSessionID());
} catch (Exception e) {
...
}
});
...
}
These lines (marked with the /* */
) that made all the difference from the previous answer, and they were already mentioned in Java Service → ext Java library (rabbit MQ client library → Service.doInvoke fails.