ackMode == ActiveMQJMSConstants.INDIVIDUAL_ACKNOWLEDGE || coreMessage.getType() == ActiveMQObjectMessage.TYPE; jmsMsg = ActiveMQMessage.createMessage(coreMessage, needSession ? coreSession : null, options); jmsMsg.setEnable1xPrefixes(true); jmsMsg.doBeforeReceive(); } catch (IndexOutOfBoundsException ioob) { ((ClientSessionInternal) session.getCoreSession()).markRollbackOnly(); IndexOutOfBoundsException newIOOB = new IndexOutOfBoundsException(ioob.getMessage() + "@" + jmsMsg.getCoreMessage()); newIOOB.initCause(ioob); ActiveMQClientLogger.LOGGER.unableToGetMessage(newIOOB); jmsMsg.setIndividualAcknowledge(); } else if (session.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE) { jmsMsg.setClientAcknowledge(); coreMessage.acknowledge(); } else {
activeMQJmsMessage = new ActiveMQTextMessage((TextMessage) jmsMessage, clientSession); } else { activeMQJmsMessage = new ActiveMQMessage(jmsMessage, clientSession); activeMQJmsMessage.getCoreMessage().setUserID(uid); activeMQJmsMessage.resetMessageID(null); jmsMessage.setJMSMessageID(activeMQJmsMessage.getJMSMessageID()); activeMQJmsMessage.setJMSDestination(destination); activeMQJmsMessage.doBeforeSend(); } catch (Exception e) { JMSException je = new JMSException(e.getMessage()); activeMQJmsMessage.setJMSDeliveryTime(System.currentTimeMillis() + defaultDeliveryDelay); ClientMessage coreMessage = activeMQJmsMessage.getCoreMessage(); coreMessage.putStringProperty(ActiveMQConnection.CONNECTION_ID_PROPERTY_NAME, connID);
@Override public void setObjectProperty(final String name, final Object value) throws JMSException { if (handleCoreProperty(name, value, MessageUtil.JMSXGROUPID, org.apache.activemq.artemis.api.core.Message.HDR_GROUP_ID)) { return; } if (handleCoreProperty(name, value, MessageUtil.JMSXUSERID, org.apache.activemq.artemis.api.core.Message.HDR_VALIDATED_USER)) { return; } if (ActiveMQJMSConstants.JMS_ACTIVEMQ_OUTPUT_STREAM.equals(name)) { setOutputStream((OutputStream) value); return; } else if (ActiveMQJMSConstants.JMS_ACTIVEMQ_SAVE_STREAM.equals(name)) { saveToOutputStream((OutputStream) value); return; } checkProperty(name); if (ActiveMQJMSConstants.JMS_ACTIVEMQ_INPUT_STREAM.equals(name)) { setInputStream((InputStream) value); return; } try { message.putObjectProperty(name, value); } catch (ActiveMQPropertyConversionException e) { throw new MessageFormatException(e.getMessage()); } }
@Override public Message createMessage() throws JMSException { checkClosed(); ActiveMQMessage message = new ActiveMQMessage(session); message.setEnable1xPrefixes(enable1xPrefixes); return message; }
@Override public ActiveMQMessage nextElement() { ActiveMQMessage msg; if (hasMoreElements()) { ClientMessage next = current; current = null; msg = ActiveMQMessage.createMessage(next, session, options); if (enable1xPrefixes) { msg.setEnable1xPrefixes(true); } try { msg.doBeforeReceive(); } catch (Exception e) { ActiveMQJMSClientLogger.LOGGER.errorCreatingMessage(msg.getCoreMessage().toString(), e); return null; } return msg; } else { throw new NoSuchElementException(); } } }
protected ActiveMQMessage(final Message foreign, final byte type, final ClientSession session) throws JMSException { this(type, session); setJMSTimestamp(foreign.getJMSTimestamp()); try { byte[] corrIDBytes = foreign.getJMSCorrelationIDAsBytes(); setJMSCorrelationIDAsBytes(corrIDBytes); } catch (JMSException e) { setJMSCorrelationID(corrIDString); setJMSCorrelationID(corrIDString); setJMSReplyTo(foreign.getJMSReplyTo()); setJMSDestination(foreign.getJMSDestination()); setJMSDeliveryMode(foreign.getJMSDeliveryMode()); setJMSExpiration(foreign.getJMSExpiration()); setJMSPriority(foreign.getJMSPriority()); setJMSType(foreign.getJMSType()); setObjectProperty(name, prop);
/** * Loads the message header fields with significant values. */ public static void configureMessage(final ActiveMQMessage m) throws JMSException { m.setJMSMessageID("ID:messageID777"); m.setJMSTimestamp(123456789L); m.setJMSCorrelationID("correlationID777"); m.setJMSReplyTo(ActiveMQJMSClient.createQueue("ReplyToQueue")); m.setJMSDestination(ActiveMQJMSClient.createQueue("DestinationQueue")); m.setJMSDeliveryMode(DeliveryMode.PERSISTENT); m.setJMSExpiration(987654321L); m.setJMSPriority(9); m.setBooleanProperty("booleanProperty", true); m.setByteProperty("byteProperty", (byte) 2); m.setShortProperty("shortProperty", (short) 3); m.setIntProperty("intProperty", 4); m.setLongProperty("longProperty", 5L); m.setFloatProperty("floatProperty", 6); m.setDoubleProperty("doubleProperty", 7); m.setStringProperty("stringPoperty", "someString"); m.setStringProperty("JMSXNaughtyProperty", "aardvark"); }
private static ClientMessage getCoreMessage(final Message jmsMessage) { if (jmsMessage instanceof ActiveMQMessage == false) { throw new IllegalArgumentException("Cannot send a foreign message as a management message " + jmsMessage.getClass().getName()); } return ((ActiveMQMessage) jmsMessage).getCoreMessage(); }
@Override public ActiveMQMessage nextElement() { ActiveMQMessage msg; if (hasMoreElements()) { ClientMessage next = current; current = null; if (enable1xPrefixes) { msg = ActiveMQCompatibleMessage.createMessage(next, session, options); } else { msg = ActiveMQMessage.createMessage(next, session, options); } try { msg.doBeforeReceive(); } catch (Exception e) { ActiveMQJMSClientLogger.LOGGER.errorCreatingMessage(msg.getCoreMessage().toString(), e); return null; } return msg; } else { throw new NoSuchElementException(); } } }
@Override public void doBeforeReceive() throws ActiveMQException { super.doBeforeReceive(); text = readBodyText(message.getBodyBuffer()); }
case ActiveMQMessage.TYPE: // 0 msg = new ActiveMQMessage(message, session); break;
ActiveMQMessage msg = ActiveMQMessage.createMessage(message, session, options); msg.setEnable1xPrefixes(activation.getConnectionFactory().isEnable1xPrefixes()); msg.doBeforeReceive();
@Test public void testCopyOnJBossMessage() throws JMSException { ClientMessage clientMessage = new ClientMessageImpl(ActiveMQTextMessage.TYPE, true, 0, System.currentTimeMillis(), (byte) 4, 1000); ClientSession session = new FakeSession(clientMessage); ActiveMQMessage jbossMessage = ActiveMQMessage.createMessage(clientMessage, session); jbossMessage.clearProperties(); MessageHeaderTestBase.configureMessage(jbossMessage); ActiveMQMessage copy = new ActiveMQMessage(jbossMessage, session); MessageHeaderTestBase.ensureEquivalent(jbossMessage, copy); }
@Override public synchronized Message read() throws Exception { reader.getRawXMLReader().nextTag(); // End of document. if (reader.getRawXMLReader().getLocalName().equals("messages")) return null; XMLMessageImporter.MessageInfo messageInfo = reader.readMessage(true); if (messageInfo == null) return null; // This is a large message ActiveMQMessage jmsMessage = new ActiveMQMessage((ClientMessage) messageInfo.message, clientSession); if (messageInfo.tempFile != null) { jmsMessage.setInputStream(new FileInputStream(messageInfo.tempFile)); } return jmsMessage; }
public static ActiveMQMessage createMessage(final ClientMessage message, final ClientSession session) { return createMessage(message, session, null); }
msg = ActiveMQCompatibleMessage.createMessage(message, session, options); } else { msg = ActiveMQMessage.createMessage(message, session, options); msg.doBeforeReceive();
protected ActiveMQMessage(final Message foreign, final byte type, final ClientSession session) throws JMSException { this(type, session); setJMSTimestamp(foreign.getJMSTimestamp()); try { byte[] corrIDBytes = foreign.getJMSCorrelationIDAsBytes(); setJMSCorrelationIDAsBytes(corrIDBytes); } catch (JMSException e) { setJMSCorrelationID(corrIDString); setJMSCorrelationID(corrIDString); setJMSReplyTo(foreign.getJMSReplyTo()); setJMSDestination(foreign.getJMSDestination()); setJMSDeliveryMode(foreign.getJMSDeliveryMode()); setJMSExpiration(foreign.getJMSExpiration()); setJMSPriority(foreign.getJMSPriority()); setJMSType(foreign.getJMSType()); setObjectProperty(name, prop);
private static ClientMessage getCoreMessage(final Message jmsMessage) { if (jmsMessage instanceof ActiveMQMessage == false) { throw new IllegalArgumentException("Cannot send a foreign message as a management message " + jmsMessage.getClass().getName()); } return ((ActiveMQMessage) jmsMessage).getCoreMessage(); }
@Override public ActiveMQMessage nextElement() { ActiveMQMessage msg; if (hasMoreElements()) { ClientMessage next = current; current = null; msg = ActiveMQMessage.createMessage(next, session, options); if (enable1xPrefixes) { msg.setEnable1xPrefixes(true); } try { msg.doBeforeReceive(); } catch (Exception e) { ActiveMQJMSClientLogger.LOGGER.errorCreatingMessage(msg.getCoreMessage().toString(), e); return null; } return msg; } else { throw new NoSuchElementException(); } } }
@Override public ActiveMQMessage nextElement() { ActiveMQMessage msg; if (hasMoreElements()) { ClientMessage next = current; current = null; if (enable1xPrefixes) { msg = ActiveMQCompatibleMessage.createMessage(next, session, options); } else { msg = ActiveMQMessage.createMessage(next, session, options); } try { msg.doBeforeReceive(); } catch (Exception e) { ActiveMQJMSClientLogger.LOGGER.errorCreatingMessage(msg.getCoreMessage().toString(), e); return null; } return msg; } else { throw new NoSuchElementException(); } } }