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


Java StreamMessage.writeByte方法代码示例

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


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

示例1: sendCompressedStreamMessageUsingOpenWire

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

   final ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination);

   StreamMessage streamMessage = session.createStreamMessage();

   streamMessage.writeBoolean(true);
   streamMessage.writeByte((byte) 10);
   streamMessage.writeBytes(TEXT.getBytes());
   streamMessage.writeChar('A');
   streamMessage.writeDouble(55.3D);
   streamMessage.writeFloat(79.1F);
   streamMessage.writeInt(37);
   streamMessage.writeLong(56652L);
   streamMessage.writeObject(new String("VVVV"));
   streamMessage.writeShort((short) 333);
   streamMessage.writeString(TEXT);

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

示例2: sendStreamMessageUsingOpenWire

import javax.jms.StreamMessage; //导入方法依赖的package包/类
private void sendStreamMessageUsingOpenWire(String queueName) 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);

   StreamMessage streamMessage = session.createStreamMessage();
   streamMessage.writeBoolean(true);
   streamMessage.writeByte((byte) 2);
   streamMessage.writeBytes(new byte[]{6, 7});
   streamMessage.writeChar('b');
   streamMessage.writeDouble(6.5);
   streamMessage.writeFloat((float) 93.9);
   streamMessage.writeInt(7657);
   streamMessage.writeLong(239999L);
   streamMessage.writeShort((short) 34222);
   streamMessage.writeString("hello streammessage");

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

示例3: sendTestStreamMessage

import javax.jms.StreamMessage; //导入方法依赖的package包/类
private void sendTestStreamMessage(ActiveMQConnectionFactory factory, String message) throws JMSException {
   ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   MessageProducer producer = session.createProducer(queue);
   StreamMessage streamMessage = session.createStreamMessage();

   streamMessage.writeBoolean(true);
   streamMessage.writeByte((byte) 10);
   streamMessage.writeBytes(TEXT.getBytes());
   streamMessage.writeChar('A');
   streamMessage.writeDouble(55.3D);
   streamMessage.writeFloat(79.1F);
   streamMessage.writeInt(37);
   streamMessage.writeLong(56652L);
   streamMessage.writeObject(new String("VVVV"));
   streamMessage.writeShort((short) 333);
   streamMessage.writeString(TEXT);

   producer.send(streamMessage);
   connection.close();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:22,代码来源:MessageCompressionTest.java

示例4: prepareMessage

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

   StreamMessage sm = (StreamMessage) m;

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

示例5: sendStreamMessageUsingCoreJms

import javax.jms.StreamMessage; //导入方法依赖的package包/类
private void sendStreamMessageUsingCoreJms(String queueName) throws Exception {
   Connection jmsConn = null;
   try {
      jmsConn = coreCf.createConnection();
      Session session = jmsConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      StreamMessage msg = session.createStreamMessage();
      msg.writeBoolean(true);
      msg.writeByte((byte) 2);
      msg.writeBytes(new byte[]{6, 7});
      msg.writeChar('b');
      msg.writeDouble(6.5);
      msg.writeFloat((float) 93.9);
      msg.writeInt(7657);
      msg.writeLong(239999L);
      msg.writeShort((short) 34222);
      msg.writeString("hello streammessage");

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

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

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

示例6: testSMBodyReadable

import javax.jms.StreamMessage; //导入方法依赖的package包/类
@Test
public void testSMBodyReadable() throws Exception {
   byte bValue = 123;
   StreamMessage sm = queueProducerSession.createStreamMessage();
   sm.writeByte(bValue);
   sm.setStringProperty("COM_SUN_JMS_TESTNAME", "xMessageEOFExceptionQTestforStreamMessage");
   queueProducer.send(sm);

   StreamMessage received = (StreamMessage) queueConsumer.receive(3000);
   received.readByte();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:12,代码来源:MessageBodyTest.java

示例7: testCopyOnForeignStreamMessage

import javax.jms.StreamMessage; //导入方法依赖的package包/类
@Test
public void testCopyOnForeignStreamMessage() throws JMSException {
   ClientMessage clientMessage = new ClientMessageImpl(ActiveMQTextMessage.TYPE, true, 0, System.currentTimeMillis(), (byte) 4, 1000);
   ClientSession session = new FakeSession(clientMessage);

   StreamMessage foreignStreamMessage = new SimpleJMSStreamMessage();
   foreignStreamMessage.writeByte((byte) 1);
   foreignStreamMessage.writeByte((byte) 2);
   foreignStreamMessage.writeByte((byte) 3);

   ActiveMQStreamMessage copy = new ActiveMQStreamMessage(foreignStreamMessage, session);

   MessageHeaderTestBase.ensureEquivalent(foreignStreamMessage, copy);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:15,代码来源:MessageHeaderTest.java

示例8: testStreamMessageEOF

import javax.jms.StreamMessage; //导入方法依赖的package包/类
public void testStreamMessageEOF() throws Exception
{
    Connection con = (AMQConnection) getConnection("guest", "guest");
    AMQSession consumerSession = (AMQSession) con.createSession(false, Session.CLIENT_ACKNOWLEDGE);

    AMQHeadersExchange queue =
        new AMQHeadersExchange(new AMQBindingURL(
                ExchangeDefaults.HEADERS_EXCHANGE_CLASS + "://" + ExchangeDefaults.HEADERS_EXCHANGE_NAME
                + "/test/queue1?" + BindingURL.OPTION_ROUTING_KEY + "='F0000=1'"));
    FieldTable ft = new FieldTable();
    ft.setString("x-match", "any");
    ft.setString("F1000", "1");
    MessageConsumer consumer =
        consumerSession.createConsumer(queue, Integer.parseInt(ClientProperties.MAX_PREFETCH_DEFAULT), Integer.parseInt(ClientProperties.MAX_PREFETCH_DEFAULT), false, false, (String) null, ft);

    // force synch to ensure the consumer has resulted in a bound queue
    // ((AMQSession) consumerSession).declareExchangeSynch(ExchangeDefaults.HEADERS_EXCHANGE_NAME, ExchangeDefaults.HEADERS_EXCHANGE_CLASS);
    // This is the default now

    Connection con2 = (AMQConnection) getConnection("guest", "guest");

    AMQSession producerSession = (AMQSession) con2.createSession(false, Session.CLIENT_ACKNOWLEDGE);

    // Need to start the "producer" connection in order to receive bounced messages
    _logger.info("Starting producer connection");
    con2.start();

    MessageProducer mandatoryProducer = producerSession.createProducer(queue);

    // Third test - should be routed
    _logger.info("Sending isBound message");
    StreamMessage msg = producerSession.createStreamMessage();

    msg.setStringProperty("F1000", "1");

    msg.writeByte((byte) 42);

    mandatoryProducer.send(msg);

    _logger.info("Starting consumer connection");
    con.start();

    StreamMessage msg2 = (StreamMessage) consumer.receive(2000);
    assertNotNull(msg2);

    msg2.readByte();
    try
    {
        msg2.readByte();
    }
    catch (Exception e)
    {
        assertTrue("Expected MessageEOFException: " + e, e instanceof MessageEOFException);
    }
    con.close();
    con2.close();
}
 
开发者ID:wso2,项目名称:andes,代码行数:58,代码来源:StreamMessageTest.java


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