use of com.swiftmq.jms.BytesMessageImpl in project swiftmq-ce by iitsoftware.
the class TopicAnnounceReceiver method run.
public void run() {
if (!closed) {
try {
topicTransaction.commit();
BytesMessageImpl msg = (BytesMessageImpl) messageEntry.getMessage();
msg.reset();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.topicManager.getName(), toString() + "/run, new message: " + msg);
byte[] b = new byte[(int) msg.getBodyLength()];
msg.readBytes(b);
dis.reset();
dis.setBuffer(b);
VersionObject vo = (VersionObject) versionObjectFactory.createDumpable(dis.readInt());
vo.readContent(dis);
vo.accept(this);
topicTransaction = topicReceiver.createTransaction(false);
topicTransaction.registerMessageProcessor(this);
} catch (Exception e) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.topicManager.getName(), toString() + "/ exception occurred: " + e + ", EXITING");
try {
ctx.queueManager.purgeQueue(topicQueue);
} catch (Exception ignored) {
}
return;
}
}
}
use of com.swiftmq.jms.BytesMessageImpl in project swiftmq-ce by iitsoftware.
the class HeuristicHandler method messageToEntity.
private void messageToEntity(MessageImpl message, Entity entity) throws Exception {
entity.setName(message.getStringProperty(PROP_SID));
BytesMessageImpl msg = (BytesMessageImpl) message;
byte[] b = new byte[(int) msg.getBodyLength()];
msg.readBytes(b);
DataByteArrayInputStream dis = new DataByteArrayInputStream(b);
XidImpl xid = new XidImpl();
xid.readContent(dis);
entity.setUserObject(xid);
entity.getProperty("xid").setValue(xid.toString());
entity.getProperty("operation").setValue(msg.getStringProperty(PROP_OPER));
}
use of com.swiftmq.jms.BytesMessageImpl in project swiftmq-ce by iitsoftware.
the class HeuristicHandler method entityToMessage.
private MessageImpl entityToMessage(Entity entity) throws Exception {
XidImpl xid = (XidImpl) entity.getUserObject();
DataByteArrayOutputStream dos = new DataByteArrayOutputStream();
xid.writeContent(dos);
BytesMessageImpl message = new BytesMessageImpl();
message.setJMSDestination(new QueueImpl(HEURISTIC_QUEUE));
message.setJMSDeliveryMode(DeliveryMode.PERSISTENT);
message.setJMSPriority(Message.DEFAULT_PRIORITY);
message.setJMSExpiration(Message.DEFAULT_TIME_TO_LIVE);
message.setJMSMessageID(MSGID + IdGenerator.getInstance().nextId('/'));
message.setStringProperty(PROP_OPER, (String) entity.getProperty(PROP_OPER).getValue());
message.setStringProperty(PROP_SID, entity.getName());
message.setIntProperty(PROP_IID, Integer.parseInt(entity.getName()));
message.writeBytes(dos.getBuffer(), 0, dos.getCount());
return message;
}
use of com.swiftmq.jms.BytesMessageImpl in project swiftmq-client by iitsoftware.
the class FileChunkRequest method toMessage.
public Message toMessage() throws JMSException {
BytesMessage message = new BytesMessageImpl();
fillMessage(message);
message.setIntProperty(ProtocolFactory.DUMPID_PROP, ProtocolFactory.FILECHUNK_REQ);
message.setIntProperty(CHUNKNO_PROP, chunkNo);
message.setIntProperty(LENGTH_PROP, len);
message.setBooleanProperty(LAST_PROP, last);
message.writeBytes(chunk, 0, len);
return message;
}
use of com.swiftmq.jms.BytesMessageImpl in project swiftmq-ce by iitsoftware.
the class BasicInboundTransformer method transform.
public MessageImpl transform(MessageWrap messageWrap, DestinationFactory destinationFactory) throws JMSException {
MessageImpl msg = null;
ContentHeaderProperties prop = messageWrap.getContentHeaderProperties();
byte[] payload = getPayload(prop.getBodySize().intValue(), messageWrap.getBodyParts());
if (prop.getContentType() != null && prop.getContentType().startsWith("text/")) {
TextMessageImpl textMessage = new TextMessageImpl();
try {
textMessage.setText(new String(payload, "utf-8"));
} catch (UnsupportedEncodingException e) {
throw new JMSException(e.toString());
}
msg = textMessage;
} else
msg = new BytesMessageImpl(payload, payload.length);
msg.setLongProperty(messageFormat, Util.MESSAGE_FORMAT);
transformHeader(msg, prop, destinationFactory);
return msg;
}
Aggregations