MessageProcessor processor = new MessageProcessor() { @Override public void run() { **new MessageProcessor()**.generate(outgoingQueue); } };
/** * Same as {@link #createMessage(ConnectionContext, BasicMessage, Map)} with <code>null</code> headers. */ protected Message createMessage(ConnectionContext context, BasicMessage basicMessage) throws JMSException { return createMessage(context, basicMessage, null); }
/** * Same as {@link #createMessage(ConnectionContext, BasicMessage, Map)} with <code>null</code> headers. */ protected Message createMessageWithBinaryData(ConnectionContext context, BasicMessage basicMessage, InputStream inputStream) throws JMSException { return createMessageWithBinaryData(context, basicMessage, inputStream, null); }
/** * If the given {@code message.getBinaryData()} is not {@code null} delegates to * {@link #sendWithBinaryData(ProducerConnectionContext, BasicMessage, InputStream, Map)} otherwise delegates to * {@link #send(ProducerConnectionContext, BasicMessageWithExtraData, Map)} * * @param context information that determines where the message is sent * @param message the message to send * @param headers headers for the JMS transport that will override same-named headers in the basic message * @return the message ID * @throws JMSException any error */ public <T extends BasicMessage> MessageId send(ProducerConnectionContext context, BasicMessageWithExtraData<T> message, Map<String, String> headers) throws JMSException { if (message.getBinaryData() == null) { return send(context, message.getBasicMessage(), headers); } else { return sendWithBinaryData(context, message.getBasicMessage(), message.getBinaryData(), headers); } }
/** * Same as {@link #sendWithBinaryData(ProducerConnectionContext, BasicMessage, InputStream, Map)} with * <code>null</code> headers. */ public MessageId sendWithBinaryData(ProducerConnectionContext context, BasicMessage basicMessage, InputStream inputStream) throws JMSException { return sendWithBinaryData(context, basicMessage, inputStream, null); }
/** * Same as {@link #send(ProducerConnectionContext, BasicMessage, Map)} with <code>null</code> headers. */ public MessageId send(ProducerConnectionContext context, BasicMessage basicMessage) throws JMSException { return send(context, basicMessage, null); }
/** * Creates a text message that can be send via a producer that contains the given BasicMessage's JSON encoded data. * * @param context the context whose session is used to create the message * @param basicMessage contains the data that will be JSON-encoded and encapsulated in the created message, with * optional headers included * @param headers headers for the Message that will override same-named headers in the basic message * @return the message that can be produced * @throws JMSException any error * @throws NullPointerException if the context is null or the context's session is null */ protected Message createMessage(ConnectionContext context, BasicMessage basicMessage, Map<String, String> headers) throws JMSException { if (context == null) { throw new IllegalArgumentException("The context is null"); } if (basicMessage == null) { throw new IllegalArgumentException("The message is null"); } Session session = context.getSession(); if (session == null) { throw new IllegalArgumentException("The context had a null session"); } TextMessage msg = session.createTextMessage(basicMessage.toJSON()); setHeaders(basicMessage, headers, msg); log.infof("Created text message [%s] with text [%s]", msg, msg.getText()); return msg; }
/** * Same as {@link #sendAndListen(ProducerConnectionContext, BasicMessage, BasicMessageListener, Map)} with * <code>null</code> headers. */ public <T extends BasicMessage> RPCConnectionContext sendAndListen(ProducerConnectionContext context, BasicMessage basicMessage, BasicMessageListener<T> responseListener) throws JMSException { return sendAndListen(context, basicMessage, responseListener, null); }
/** * If the given {@code message.getBinaryData()} is not {@code null} delegates to * {@link #sendWithBinaryData(ProducerConnectionContext, BasicMessage, InputStream, Map)} otherwise delegates to * {@link #send(ProducerConnectionContext, BasicMessageWithExtraData, Map)} * * @param context information that determines where the message is sent * @param message the message to send * @param headers headers for the JMS transport that will override same-named headers in the basic message * @return the message ID * @throws JMSException any error */ public <T extends BasicMessage> MessageId send(ProducerConnectionContext context, BasicMessageWithExtraData<T> message, Map<String, String> headers) throws JMSException { if (message.getBinaryData() == null) { return send(context, message.getBasicMessage(), headers); } else { return sendWithBinaryData(context, message.getBasicMessage(), message.getBinaryData(), headers); } }
/** * Same as {@link #sendWithBinaryData(ProducerConnectionContext, BasicMessage, InputStream, Map)} with * <code>null</code> headers. */ public MessageId sendWithBinaryData(ProducerConnectionContext context, BasicMessage basicMessage, InputStream inputStream) throws JMSException { return sendWithBinaryData(context, basicMessage, inputStream, null); }
/** * Same as {@link #send(ProducerConnectionContext, BasicMessage, Map)} with <code>null</code> headers. */ public MessageId send(ProducerConnectionContext context, BasicMessage basicMessage) throws JMSException { return send(context, basicMessage, null); }
/** * Creates a text message that can be send via a producer that contains the given BasicMessage's JSON encoded data. * * @param context the context whose session is used to create the message * @param basicMessage contains the data that will be JSON-encoded and encapsulated in the created message, with * optional headers included * @param headers headers for the Message that will override same-named headers in the basic message * @return the message that can be produced * @throws JMSException any error * @throws NullPointerException if the context is null or the context's session is null */ protected Message createMessage(ConnectionContext context, BasicMessage basicMessage, Map<String, String> headers) throws JMSException { if (context == null) { throw new IllegalArgumentException("The context is null"); } if (basicMessage == null) { throw new IllegalArgumentException("The message is null"); } Session session = context.getSession(); if (session == null) { throw new IllegalArgumentException("The context had a null session"); } TextMessage msg = session.createTextMessage(basicMessage.toJSON()); setHeaders(basicMessage, headers, msg); log.debugf("Created text message [%s] with text [%s]", msg, msg.getText()); return msg; }
/** * Same as {@link #sendAndListen(ProducerConnectionContext, BasicMessage, BasicMessageListener, Map)} with * <code>null</code> headers. */ public <T extends BasicMessage> RPCConnectionContext sendAndListen(ProducerConnectionContext context, BasicMessage basicMessage, BasicMessageListener<T> responseListener) throws JMSException { return sendAndListen(context, basicMessage, responseListener, null); }
public class ConnectionManager { public void connect() { MessageProcessor pm = new MessageProcessor(this); } public void setConnected(boolean connected) { this.connected = connected; } }
/** * Same as {@link #sendWithBinaryData(ProducerConnectionContext, BasicMessage, InputStream, Map)} with the input * stream being a stream to read the file. * * @throws FileNotFoundException if the file does not exist */ public MessageId sendWithBinaryData(ProducerConnectionContext context, BasicMessage basicMessage, File file, Map<String, String> headers) throws JMSException, FileNotFoundException { return sendWithBinaryData(context, basicMessage, new FileInputStream(file), headers); }
/** * Same as {@link #createMessage(ConnectionContext, BasicMessage, Map)} with <code>null</code> headers. */ protected Message createMessage(ConnectionContext context, BasicMessage basicMessage) throws JMSException { return createMessage(context, basicMessage, null); }
sessionProducer = session.createProducer(replyTo); producerContext.setMessageProducer(sessionProducer); sender.send(producerContext, responseBasicMessage);
/** * Same as {@link #createMessage(ConnectionContext, BasicMessage, Map)} with <code>null</code> headers. */ protected Message createMessageWithBinaryData(ConnectionContext context, BasicMessage basicMessage, InputStream inputStream) throws JMSException { return createMessageWithBinaryData(context, basicMessage, inputStream, null); }
msg.setObjectProperty("JMS_AMQ_InputStream", messagePlusBinaryData); setHeaders(basicMessage, headers, msg);
MessageProcessor processor = new MessageProcessor() { @Override final public void run() { MessageProcessor(outgoingQueue).generate(outgoingQueue); } };