protected Queue queueWrapper(String name, javax.jms.Queue queue, Messaging broker) { return new JMSQueue(name, queue, (JMSMessagingSkeleton)broker); }
@Override public Listener respond(final MessageHandler handler, final Codecs codecs, Map<ListenOption, Object> options) throws Exception { final Options<ListenOption> opts = new Options<>(options); String selector = JMSMessage.SYNC_PROPERTY + " = TRUE"; if (opts.has(ListenOption.SELECTOR)) { selector += " AND " + opts.getString(ListenOption.SELECTOR); } opts.put(ListenOption.SELECTOR, selector); MessageHandler wrappedHandler = new MessageHandler() { @Override public Reply onMessage(Message msg, Context context) throws Exception { Reply result = handler.onMessage(msg, context); Options<MessageOpOption> replyOptions = new Options<>(); replyOptions.put(PublishOption.TTL, opts.getInt(RespondOption.TTL)); replyOptions.put(PublishOption.CONTEXT, context); replyOptions.put(PublishOption.PROPERTIES, result.properties()); ((ReplyableMessage)msg).reply(result.content(), codecs.forContentType(msg.contentType()), replyOptions); return null; } }; return listen(wrappedHandler, codecs, opts); }
@Override public Response request(Object content, Codec codec, Codecs codecs, Map<MessageOpOption, Object> options) throws Exception { final Options<MessageOpOption> opts = new Options<>(options); final String id = UUID.randomUUID().toString(); final JMSSpecificContext context = (JMSSpecificContext)opts.get(MessageOpOption.CONTEXT); final String nodeId = context != null ? context.id() : JMSMessagingSkeleton.BROKER_ID; final ConcreteResponse response = new ConcreteResponse(); Options<ListenOption> routerOpts = new Options<>(); routerOpts.put(ListenOption.CONCURRENCY, 1); routerOpts.put(ListenOption.SELECTOR, JMSMessage.REQUEST_NODE_ID_PROPERTY + " = '" + nodeId + "' AND " + JMSMessage.SYNC_RESPONSE_PROPERTY + " = TRUE"); if (context != null && context.isRemote()) { routerOpts.put(ListenOption.CONTEXT, context); } ResponseRouter.routerFor(this, codecs, routerOpts).registerResponse(id, response); publish(content, codec, options, new HashMap<String, Object>() {{ put(JMSMessage.REQUEST_NODE_ID_PROPERTY, nodeId); put(JMSMessage.SYNC_PROPERTY, true); put(JMSMessage.REQUEST_ID_PROPERTY, id); }}); return response; }