本文整理匯總了Java中javax.jms.BytesMessage.writeUTF方法的典型用法代碼示例。如果您正苦於以下問題:Java BytesMessage.writeUTF方法的具體用法?Java BytesMessage.writeUTF怎麽用?Java BytesMessage.writeUTF使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.jms.BytesMessage
的用法示例。
在下文中一共展示了BytesMessage.writeUTF方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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();
}
}
}
示例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);
}
示例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();
}
示例4: newMessage
import javax.jms.BytesMessage; //導入方法依賴的package包/類
Message newMessage(final String body, final String deviceId, final String token) throws JMSException {
final BytesMessage message = session.createBytesMessage();
message.setStringProperty(MessageHelper.APP_PROPERTY_DEVICE_ID, deviceId);
message.setStringProperty(MessageHelper.APP_PROPERTY_REGISTRATION_ASSERTION, token);
message.writeUTF(body);
return message;
}