本文整理汇总了Java中javax.jms.MapMessage.setLong方法的典型用法代码示例。如果您正苦于以下问题:Java MapMessage.setLong方法的具体用法?Java MapMessage.setLong怎么用?Java MapMessage.setLong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jms.MapMessage
的用法示例。
在下文中一共展示了MapMessage.setLong方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendCompressedMapMessageUsingOpenWire
import javax.jms.MapMessage; //导入方法依赖的package包/类
private void sendCompressedMapMessageUsingOpenWire() throws Exception {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE);
final ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination);
MapMessage mapMessage = session.createMapMessage();
mapMessage.setBoolean("boolean-type", true);
mapMessage.setByte("byte-type", (byte) 10);
mapMessage.setBytes("bytes-type", TEXT.getBytes());
mapMessage.setChar("char-type", 'A');
mapMessage.setDouble("double-type", 55.3D);
mapMessage.setFloat("float-type", 79.1F);
mapMessage.setInt("int-type", 37);
mapMessage.setLong("long-type", 56652L);
mapMessage.setObject("object-type", new String("VVVV"));
mapMessage.setShort("short-type", (short) 333);
mapMessage.setString("string-type", TEXT);
producer.send(mapMessage);
}
示例2: sendMapMessageUsingOpenWire
import javax.jms.MapMessage; //导入方法依赖的package包/类
private void sendMapMessageUsingOpenWire() 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);
MapMessage mapMessage = session.createMapMessage();
mapMessage.setBoolean("aboolean", true);
mapMessage.setByte("abyte", (byte) 4);
mapMessage.setBytes("abytes", new byte[]{4, 5});
mapMessage.setChar("achar", 'a');
mapMessage.setDouble("adouble", 4.4);
mapMessage.setFloat("afloat", 4.5f);
mapMessage.setInt("aint", 40);
mapMessage.setLong("along", 80L);
mapMessage.setShort("ashort", (short) 65);
mapMessage.setString("astring", "hello");
producer.send(mapMessage);
}
示例3: sendTestMapMessage
import javax.jms.MapMessage; //导入方法依赖的package包/类
private void sendTestMapMessage(ActiveMQConnectionFactory factory, String message) throws JMSException {
ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(queue);
MapMessage mapMessage = session.createMapMessage();
mapMessage.setBoolean("boolean-type", true);
mapMessage.setByte("byte-type", (byte) 10);
mapMessage.setBytes("bytes-type", TEXT.getBytes());
mapMessage.setChar("char-type", 'A');
mapMessage.setDouble("double-type", 55.3D);
mapMessage.setFloat("float-type", 79.1F);
mapMessage.setInt("int-type", 37);
mapMessage.setLong("long-type", 56652L);
mapMessage.setObject("object-type", new String("VVVV"));
mapMessage.setShort("short-type", (short) 333);
mapMessage.setString("string-type", TEXT);
producer.send(mapMessage);
connection.close();
}
示例4: prepareMessage
import javax.jms.MapMessage; //导入方法依赖的package包/类
@Override
protected void prepareMessage(final Message m) throws JMSException {
super.prepareMessage(m);
MapMessage mm = (MapMessage) m;
mm.setBoolean("boolean", true);
mm.setByte("byte", (byte) 3);
mm.setBytes("bytes", new byte[]{(byte) 3, (byte) 4, (byte) 5});
mm.setChar("char", (char) 6);
mm.setDouble("double", 7.0);
mm.setFloat("float", 8.0f);
mm.setInt("int", 9);
mm.setLong("long", 10L);
mm.setObject("object", new String("this is an object"));
mm.setShort("short", (short) 11);
mm.setString("string", "this is a string");
}
示例5: testResendWithLargeMessage
import javax.jms.MapMessage; //导入方法依赖的package包/类
@Test
public void testResendWithLargeMessage() throws Exception {
conn = cf.createConnection();
conn.start();
Session sess = conn.createSession(true, Session.SESSION_TRANSACTED);
ArrayList<Message> msgs = new ArrayList<>();
for (int i = 0; i < 10; i++) {
BytesMessage bm = sess.createBytesMessage();
bm.setObjectProperty(ActiveMQJMSConstants.JMS_ACTIVEMQ_INPUT_STREAM, ActiveMQTestBase.createFakeLargeStream(2 * ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE));
msgs.add(bm);
MapMessage mm = sess.createMapMessage();
mm.setBoolean("boolean", true);
mm.setByte("byte", (byte) 3);
mm.setBytes("bytes", new byte[]{(byte) 3, (byte) 4, (byte) 5});
mm.setChar("char", (char) 6);
mm.setDouble("double", 7.0);
mm.setFloat("float", 8.0f);
mm.setInt("int", 9);
mm.setLong("long", 10L);
mm.setObject("object", new String("this is an object"));
mm.setShort("short", (short) 11);
mm.setString("string", "this is a string");
msgs.add(mm);
msgs.add(sess.createTextMessage("hello" + i));
msgs.add(sess.createObjectMessage(new SomeSerializable("hello" + i)));
}
internalTestResend(msgs, sess);
}
示例6: testResendWithMapMessagesOnly
import javax.jms.MapMessage; //导入方法依赖的package包/类
@Test
public void testResendWithMapMessagesOnly() throws Exception {
conn = cf.createConnection();
conn.start();
Session sess = conn.createSession(true, Session.SESSION_TRANSACTED);
ArrayList<Message> msgs = new ArrayList<>();
for (int i = 0; i < 1; i++) {
MapMessage mm = sess.createMapMessage();
mm.setBoolean("boolean", true);
mm.setByte("byte", (byte) 3);
mm.setBytes("bytes", new byte[]{(byte) 3, (byte) 4, (byte) 5});
mm.setChar("char", (char) 6);
mm.setDouble("double", 7.0);
mm.setFloat("float", 8.0f);
mm.setInt("int", 9);
mm.setLong("long", 10L);
mm.setObject("object", new String("this is an object"));
mm.setShort("short", (short) 11);
mm.setString("string", "this is a string");
msgs.add(mm);
MapMessage emptyMap = sess.createMapMessage();
msgs.add(emptyMap);
}
internalTestResend(msgs, sess);
}
示例7: sendMapMessageUsingCoreJms
import javax.jms.MapMessage; //导入方法依赖的package包/类
private void sendMapMessageUsingCoreJms(String queueName) throws Exception {
Connection jmsConn = null;
try {
jmsConn = coreCf.createConnection();
Session session = jmsConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MapMessage mapMessage = session.createMapMessage();
mapMessage.setBoolean("aboolean", true);
mapMessage.setByte("abyte", (byte) 4);
mapMessage.setBytes("abytes", new byte[]{4, 5});
mapMessage.setChar("achar", 'a');
mapMessage.setDouble("adouble", 4.4);
mapMessage.setFloat("afloat", 4.5f);
mapMessage.setInt("aint", 40);
mapMessage.setLong("along", 80L);
mapMessage.setShort("ashort", (short) 65);
mapMessage.setString("astring", "hello");
Queue queue = session.createQueue(queueName);
MessageProducer producer = session.createProducer(queue);
producer.send(mapMessage);
} finally {
if (jmsConn != null) {
jmsConn.close();
}
}
}
示例8: send
import javax.jms.MapMessage; //导入方法依赖的package包/类
@Override
public JMSProducer send(Destination destination, Map<String, Object> body) {
MapMessage message = context.createMapMessage();
if (body != null) {
try {
for (Entry<String, Object> entry : body.entrySet()) {
final String name = entry.getKey();
final Object v = entry.getValue();
if (v instanceof String) {
message.setString(name, (String) v);
} else if (v instanceof Long) {
message.setLong(name, (Long) v);
} else if (v instanceof Double) {
message.setDouble(name, (Double) v);
} else if (v instanceof Integer) {
message.setInt(name, (Integer) v);
} else if (v instanceof Character) {
message.setChar(name, (Character) v);
} else if (v instanceof Short) {
message.setShort(name, (Short) v);
} else if (v instanceof Boolean) {
message.setBoolean(name, (Boolean) v);
} else if (v instanceof Float) {
message.setFloat(name, (Float) v);
} else if (v instanceof Byte) {
message.setByte(name, (Byte) v);
} else if (v instanceof byte[]) {
byte[] array = (byte[]) v;
message.setBytes(name, array, 0, array.length);
} else {
message.setObject(name, v);
}
}
} catch (JMSException e) {
throw new MessageFormatRuntimeException(e.getMessage());
}
}
send(destination, message);
return this;
}
示例9: marshal
import javax.jms.MapMessage; //导入方法依赖的package包/类
public Message marshal(EventBean eventBean, Session session,
long timestamp) throws EPException {
EventType eventType = eventBean.getEventType();
MapMessage mapMessage = null;
try {
mapMessage = session.createMapMessage();
String[] properties = eventType.getPropertyNames();
for (String property : properties) {
if ((ExecutionPathDebugLog.isDebugEnabled) && (log.isDebugEnabled())) {
log.debug(
".Marshal EventProperty property==" + property + ", value=" +
eventBean.get(property));
}
Class clazz = eventType.getPropertyType(property);
if (JavaClassHelper.isNumeric(clazz)) {
Class boxedClazz = JavaClassHelper.getBoxedType(clazz);
if (boxedClazz == Double.class) {
mapMessage.setDouble(property, (Double) eventBean.get(property));
}
if (boxedClazz == Float.class) {
mapMessage.setFloat(property, (Float) eventBean.get(property));
}
if (boxedClazz == Byte.class) {
mapMessage.setFloat(property, (Byte) eventBean.get(property));
}
if (boxedClazz == Short.class) {
mapMessage.setShort(property, (Short) eventBean.get(property));
}
if (boxedClazz == Integer.class) {
mapMessage.setInt(property, (Integer) eventBean.get(property));
}
if (boxedClazz == Long.class) {
mapMessage.setLong(property, (Long) eventBean.get(property));
}
} else if ((clazz == boolean.class) || (clazz == Boolean.class)) {
mapMessage.setBoolean(property, (Boolean) eventBean.get(property));
} else if ((clazz == Character.class) || (clazz == char.class)) {
mapMessage.setChar(property, (Character) eventBean.get(property));
} else if (clazz == String.class) {
mapMessage.setString(property, (String) eventBean.get(property));
} else {
mapMessage.setObject(property, eventBean.get(property));
}
}
mapMessage.setJMSTimestamp(timestamp);
} catch (JMSException ex) {
throw new EPException(ex);
}
return mapMessage;
}
示例10: createBodySendAndReceive
import javax.jms.MapMessage; //导入方法依赖的package包/类
/**
* @param type
* @throws JMSException
*/
private Object createBodySendAndReceive(JmsMessageType type) throws JMSException {
Object res = null;
Message msg = null;
switch (type) {
case BYTE:
BytesMessage mByte = queueProducerSession.createBytesMessage();
final int size = 20;
byte[] resByte = new byte[size];
for (int i = 0; i < size; i++) {
resByte[i] = (byte) i;
mByte.writeByte((byte) i);
}
msg = mByte;
res = resByte;
break;
case TEXT:
res = "JMS2";
msg = queueProducerSession.createTextMessage("JMS2");
break;
case STREAM:
msg = queueProducerSession.createStreamMessage();
break;
case OBJECT:
res = new Double(37.6);
msg = queueProducerSession.createObjectMessage(new Double(37.6));
break;
case MAP:
MapMessage msg1 = queueProducerSession.createMapMessage();
msg1.setInt("int", 13);
msg1.setLong("long", 37L);
msg1.setString("string", "crocodile");
msg = msg1;
Map<String, Object> map = new HashMap<>();
map.put("int", Integer.valueOf(13));
map.put("long", Long.valueOf(37L));
map.put("string", "crocodile");
res = map;
break;
default:
Assert.fail("no default...");
}
Assert.assertNotNull(msg);
msg.setStringProperty("type", type.toString());
queueProducer.send(msg);
return res;
}