本文整理汇总了Java中javax.jms.StreamMessage.writeBoolean方法的典型用法代码示例。如果您正苦于以下问题:Java StreamMessage.writeBoolean方法的具体用法?Java StreamMessage.writeBoolean怎么用?Java StreamMessage.writeBoolean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jms.StreamMessage
的用法示例。
在下文中一共展示了StreamMessage.writeBoolean方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSendStreamMessage
import javax.jms.StreamMessage; //导入方法依赖的package包/类
@Test
public void testSendStreamMessage() throws JMSException, InterruptedException {
JmsProducerCompletionListenerTest.CountingCompletionListener cl = new JmsProducerCompletionListenerTest.CountingCompletionListener(1);
JMSProducer producer = context.createProducer();
producer.setAsync(cl);
StreamMessage msg = context.createStreamMessage();
msg.setStringProperty("name", name.getMethodName());
String bprop = "booleanProp";
String iprop = "intProp";
msg.setBooleanProperty(bprop, true);
msg.setIntProperty(iprop, 42);
msg.writeBoolean(true);
msg.writeInt(67);
producer.send(queue1, msg);
JMSConsumer consumer = context.createConsumer(queue1);
Message msg2 = consumer.receive(100);
Assert.assertNotNull(msg2);
Assert.assertTrue(cl.completionLatch.await(1, TimeUnit.SECONDS));
StreamMessage sm = (StreamMessage) cl.lastMessage;
Assert.assertEquals(true, sm.getBooleanProperty(bprop));
Assert.assertEquals(42, sm.getIntProperty(iprop));
Assert.assertEquals(true, sm.readBoolean());
Assert.assertEquals(67, sm.readInt());
}
示例2: 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);
}
示例3: 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);
}
示例4: testStreamMessageSendReceive
import javax.jms.StreamMessage; //导入方法依赖的package包/类
private void testStreamMessageSendReceive(Connection producerConnection, Connection consumerConnection) throws Throwable {
Session session = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue(getQueueName());
MessageProducer producer = session.createProducer(queue);
for (int i = 0; i < NUM_MESSAGES; i++) {
StreamMessage message = session.createStreamMessage();
message.writeInt(i);
message.writeBoolean(true);
message.writeString("test");
producer.send(message);
}
Session sessionConsumer = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue consumerQueue = sessionConsumer.createQueue(getQueueName());
final MessageConsumer consumer = sessionConsumer.createConsumer(consumerQueue);
for (int i = 0; i < NUM_MESSAGES; i++) {
StreamMessage m = (StreamMessage) consumer.receive(5000);
Assert.assertNotNull("Could not receive message count=" + i + " on consumer", m);
Assert.assertEquals(i, m.readInt());
Assert.assertEquals(true, m.readBoolean());
Assert.assertEquals("test", m.readString());
}
}
示例5: 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();
}
示例6: 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");
}
示例7: 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();
}
}
}