当前位置: 首页>>代码示例>>Java>>正文


Java BytesMessage.writeLong方法代码示例

本文整理汇总了Java中javax.jms.BytesMessage.writeLong方法的典型用法代码示例。如果您正苦于以下问题:Java BytesMessage.writeLong方法的具体用法?Java BytesMessage.writeLong怎么用?Java BytesMessage.writeLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.jms.BytesMessage的用法示例。


在下文中一共展示了BytesMessage.writeLong方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendBytesMessageUsingCoreJms

import javax.jms.BytesMessage; //导入方法依赖的package包/类
private void sendBytesMessageUsingCoreJms(String queueName, byte[] data) throws Exception {
   Connection jmsConn = null;
   try {
      jmsConn = coreCf.createConnection();
      Session session = jmsConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      BytesMessage bytesMessage = session.createBytesMessage();

      bytesMessage.writeBytes(data);
      bytesMessage.writeBoolean(true);
      bytesMessage.writeLong(99999L);
      bytesMessage.writeChar('h');
      bytesMessage.writeInt(987);
      bytesMessage.writeShort((short) 1099);
      bytesMessage.writeUTF("hellobytes");

      Queue queue = session.createQueue(queueName);
      MessageProducer producer = session.createProducer(queue);

      producer.send(bytesMessage);
   } finally {
      if (jmsConn != null) {
         jmsConn.close();
      }
   }

}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:27,代码来源:GeneralInteropTest.java

示例2: sendBytesMessageUsingOpenWire

import javax.jms.BytesMessage; //导入方法依赖的package包/类
private void sendBytesMessageUsingOpenWire(byte[] bytesData) throws Exception {
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE);

   System.out.println("destination: " + destination);
   final ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination);

   BytesMessage bytesMessage = session.createBytesMessage();
   bytesMessage.writeBytes(bytesData);
   bytesMessage.writeBoolean(true);
   bytesMessage.writeLong(99999L);
   bytesMessage.writeChar('h');
   bytesMessage.writeInt(987);
   bytesMessage.writeShort((short) 1099);
   bytesMessage.writeUTF("hellobytes");

   producer.send(bytesMessage);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:19,代码来源:GeneralInteropTest.java

示例3: prepareMessage

import javax.jms.BytesMessage; //导入方法依赖的package包/类
@Override
protected void prepareMessage(final Message m) throws JMSException {
   super.prepareMessage(m);

   BytesMessage bm = (BytesMessage) m;

   bm.writeBoolean(true);
   bm.writeByte((byte) 3);
   bm.writeBytes(new byte[]{(byte) 4, (byte) 5, (byte) 6});
   bm.writeChar((char) 7);
   bm.writeDouble(8.0);
   bm.writeFloat(9.0f);
   bm.writeInt(10);
   bm.writeLong(11L);
   bm.writeShort((short) 12);
   bm.writeUTF("this is an UTF String");
   bm.reset();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:19,代码来源:BytesMessageTest.java

示例4: writeWindowId

import javax.jms.BytesMessage; //导入方法依赖的package包/类
private void writeWindowId(String appId, int operatorId, long windowId) throws JMSException
{
  BytesMessage message = getBase().getSession().createBytesMessage();
  message.setStringProperty(APP_OPERATOR_ID, appId + "_" + operatorId);
  message.writeLong(windowId);
  producer.send(message);
  logger.debug("Message with windowId {} sent", windowId);
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:9,代码来源:JMSTransactionableStore.java

示例5: testReceiveBytes

import javax.jms.BytesMessage; //导入方法依赖的package包/类
@Test
public void testReceiveBytes() throws Exception {
   JMSProducer producer = context.createProducer();

   JMSConsumer consumer = context.createConsumer(queue1);

   BytesMessage bytesSend = context.createBytesMessage();
   bytesSend.writeByte((byte) 1);
   bytesSend.writeLong(2L);
   producer.send(queue1, bytesSend);

   BytesMessage msgReceived = (BytesMessage) consumer.receiveNoWait();

   byte[] bytesArray = msgReceived.getBody(byte[].class);

   assertEquals((byte) 1, msgReceived.readByte());
   assertEquals(2L, msgReceived.readLong());

   DataInputStream dataInputStream = new DataInputStream(new ByteArrayInputStream(bytesArray));

   assertEquals((byte) 1, dataInputStream.readByte());
   assertEquals(2L, dataInputStream.readLong());

}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:25,代码来源:JmsContextTest.java


注:本文中的javax.jms.BytesMessage.writeLong方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。