use of javax.jms.ObjectMessage in project openolat by klemens.
the class CertificatesManagerImpl method onMessage.
@Override
public void onMessage(Message message) {
if (message instanceof ObjectMessage) {
try {
ObjectMessage objMsg = (ObjectMessage) message;
JmsCertificateWork workUnit = (JmsCertificateWork) objMsg.getObject();
doCertificate(workUnit);
message.acknowledge();
} catch (JMSException e) {
log.error("", e);
} finally {
dbInstance.commitAndCloseSession();
}
}
}
use of javax.jms.ObjectMessage in project tech by ffyyhh995511.
the class RequestSubmit method submit.
public void submit(HashMap<Serializable, Serializable> requestParam) throws Exception {
ObjectMessage message = session.createObjectMessage(requestParam);
producer.send(message);
session.commit();
}
use of javax.jms.ObjectMessage in project cayenne by apache.
the class JMSBridge method sendExternalEvent.
@Override
protected void sendExternalEvent(CayenneEvent localEvent) throws Exception {
ObjectMessage message = sendSession.createObjectMessage(eventToMessageObject(localEvent));
message.setObjectProperty(JMSBridge.VM_ID_PROPERTY, JMSBridge.VM_ID);
publisher.publish(message);
}
use of javax.jms.ObjectMessage in project vcell by virtualcell.
the class VCMessageJms method show.
public String show() {
StringBuffer buffer = new StringBuffer();
try {
java.util.Enumeration enum1 = jmsMessage.getPropertyNames();
while (enum1.hasMoreElements()) {
String propName = (String) enum1.nextElement();
try {
String value = jmsMessage.getStringProperty(propName);
buffer.append(" " + propName + "='" + value + "'");
} catch (MessagePropertyNotFoundException ex) {
// definitely should not happen
delegate.onException(ex);
}
}
int maxContentLength = 120;
if (jmsMessage instanceof TextMessage) {
buffer.append(" textContent='");
String textContent = ((TextMessage) jmsMessage).getText();
if (textContent != null && textContent.length() > maxContentLength) {
buffer.append(textContent.substring(0, maxContentLength - 3) + "...");
} else {
buffer.append(textContent);
}
buffer.append("'");
} else if (jmsMessage instanceof ObjectMessage) {
buffer.append(" objectContent='");
String text = "" + ((ObjectMessage) jmsMessage).getObject();
if (text.length() > maxContentLength) {
buffer.append(text.substring(0, maxContentLength - 3) + "...");
} else {
buffer.append(text);
}
buffer.append("'");
}
} catch (JMSException e) {
e.printStackTrace(System.out);
throw new RuntimeException(e.getMessage(), e);
}
return buffer.toString();
}
use of javax.jms.ObjectMessage in project rocketmq-externals by apache.
the class BaseJmsSourceTask method getMessageContent.
@SuppressWarnings("unchecked")
public ByteBuffer getMessageContent(Message message) throws JMSException {
byte[] data = null;
if (message instanceof TextMessage) {
data = ((TextMessage) message).getText().getBytes();
} else if (message instanceof ObjectMessage) {
data = JSON.toJSONBytes(((ObjectMessage) message).getObject());
} else if (message instanceof BytesMessage) {
BytesMessage bytesMessage = (BytesMessage) message;
data = new byte[(int) bytesMessage.getBodyLength()];
bytesMessage.readBytes(data);
} else if (message instanceof MapMessage) {
MapMessage mapMessage = (MapMessage) message;
Map<String, Object> map = new HashMap<>();
Enumeration<Object> names = mapMessage.getMapNames();
while (names.hasMoreElements()) {
String name = names.nextElement().toString();
map.put(name, mapMessage.getObject(name));
}
data = JSON.toJSONBytes(map);
} else if (message instanceof StreamMessage) {
StreamMessage streamMessage = (StreamMessage) message;
ByteArrayOutputStream bis = new ByteArrayOutputStream();
byte[] by = new byte[1024];
int i = 0;
while ((i = streamMessage.readBytes(by)) != -1) {
bis.write(by, 0, i);
}
data = bis.toByteArray();
} else {
// The exception is printed and does not need to be written as a DataConnectException
throw new RuntimeException("message type exception");
}
return ByteBuffer.wrap(data);
}
Aggregations