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(); } } }
IndexOutOfBoundsException newIOOB = new IndexOutOfBoundsException(ioob.getMessage() + "@" + jmsMsg.getCoreMessage()); newIOOB.initCause(ioob); ActiveMQClientLogger.LOGGER.unableToGetMessage(newIOOB);
activeMQJmsMessage.getCoreMessage().setUserID(uid); ClientMessage coreMessage = activeMQJmsMessage.getCoreMessage(); coreMessage.putStringProperty(ActiveMQConnection.CONNECTION_ID_PROPERTY_NAME, connID);
msg.doBeforeReceive(); } catch (Exception e) { ActiveMQJMSClientLogger.LOGGER.errorPreparingMessageForReceipt(msg.getCoreMessage().toString(), e); return;
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(); }
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(); }
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(); }
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 synchronized void write(Message message) { try { ICoreMessage core = ((ActiveMQMessage) message).getCoreMessage(); writer.printSingleMessageAsXML(core, null, true); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public synchronized void write(Message message) { try { ICoreMessage core = ((ActiveMQMessage) message).getCoreMessage(); writer.printSingleMessageAsXML(core, null, true); } catch (Exception e) { throw new RuntimeException(e); } }
private void sendMessage(MessageProducer producer, String threadName) throws Exception { Message message = createMessage(sentCount.get(), threadName); if (queueId != null) { ((ActiveMQMessage) message).getCoreMessage().putBytesProperty(org.apache.activemq.artemis.api.core.Message.HDR_ROUTE_TO_IDS, queueId); } producer.send(message); if (verbose) { System.out.println(threadName + " Sent: " + (message instanceof TextMessage ? ((TextMessage) message).getText() : message.getJMSMessageID())); } if (transactionBatchSize > 0 && sentCount.get() > 0 && sentCount.get() % transactionBatchSize == 0) { System.out.println(threadName + " Committing transaction: " + transactions++); session.commit(); } if (sleep > 0) { Thread.sleep(sleep); } }
private void sendMessage(MessageProducer producer, String threadName) throws Exception { Message message = createMessage(sentCount.get(), threadName); if (queueId != null) { ((ActiveMQMessage) message).getCoreMessage().putBytesProperty(org.apache.activemq.artemis.api.core.Message.HDR_ROUTE_TO_IDS, queueId); } producer.send(message); if (verbose) { System.out.println(threadName + " Sent: " + (message instanceof TextMessage ? ((TextMessage) message).getText() : message.getJMSMessageID())); } if (transactionBatchSize > 0 && sentCount.get() > 0 && sentCount.get() % transactionBatchSize == 0) { System.out.println(threadName + " Committing transaction: " + transactions++); session.commit(); } if (sleep > 0) { Thread.sleep(sleep); } }
@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 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; 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 void setProperty(Message message) { ((ActiveMQMessage) message).getCoreMessage().putStringProperty(org.apache.activemq.artemis.api.core.Message.HDR_GROUP_ID, new SimpleString("foo")); }
protected void consumeDurableTestMessages(Connection connection, String sub, int size, String topicName, AtomicLong publishedMessageSize) throws Exception { Session session = connection.createSession(false, QueueSession.AUTO_ACKNOWLEDGE); Topic topic = session.createTopic(topicName); try { TopicSubscriber consumer = session.createDurableSubscriber(topic, sub); for (int i = 0; i < size; i++) { ActiveMQMessage message = (ActiveMQMessage) consumer.receive(); if (publishedMessageSize != null) { publishedMessageSize.addAndGet(-message.getCoreMessage().getEncodeSize()); } } } finally { session.close(); } }
protected void setProperty(Message message) { if (coreSend) { ((ActiveMQMessage) message).getCoreMessage().putStringProperty(org.apache.activemq.artemis.api.core.Message.HDR_GROUP_ID, new SimpleString("foo")); } else { org.apache.activemq.command.ActiveMQMessage m = (org.apache.activemq.command.ActiveMQMessage) message; m.setGroupID("foo"); } } }
@Override public void run() { try { // wait for 3 secs Thread.sleep(3000); // send an expired message Message m = queueProducerSession.createMessage(); queueProducer.send(m, DeliveryMode.NON_PERSISTENT, 4, -1); ActiveMQMessage msg = (ActiveMQMessage) m; if (!msg.getCoreMessage().isExpired()) { log.error("The message " + m + " should have expired"); testFailed = true; return; } } catch (Exception e) { log.error("This exception will fail the test", e); testFailed = true; } finally { senderLatch.countDown(); } } }, "sender thread");