public void send(Object replyTo, short rval, int rcode, byte[] data,
int len, int correlationId, int flags, int ttl, String type,
String subtype) throws ConnectionException {
if (closed) {
throw new ConnectionException(Connection.TPEPROTO, "Sender closed");
}
if (data == null) {
data = new byte[1];
len = 1;
}
if (len < 1) {
throw new ConnectionException(Connection.TPEINVAL,
"Length of buffer must be greater than 0");
}
log.debug("Sender sending: " + name);
try {
BytesMessage message = session.createBytesMessage();
String ior = JtsTransactionImple.getTransactionIOR();
message.setStringProperty("messagecontrol", ior);
log.debug("Sender sending IOR: " + ior);
if (replyTo != null) {
message.setStringProperty("messagereplyto", (String) replyTo);
}
message.setStringProperty("servicename", name);
message.setStringProperty("messagecorrelationId",
String.valueOf(correlationId));
message.setStringProperty("messageflags", String.valueOf(flags));
message.setStringProperty("messagerval", String.valueOf(rval));
message.setStringProperty("messagercode", String.valueOf(rcode));
message.setStringProperty("messagetype", type == null ? "" : type);
message.setStringProperty("messagesubtype", subtype == null ? ""
: subtype);
byte[] toSend = new byte[len + pad];
if (data != null) {
int min = Math.min(toSend.length, data.length);
System.arraycopy(data, 0, toSend, 0, min);
}
message.writeBytes(toSend, 0, toSend.length);
if (ttl > 0) {
int deliveryMode = message.getJMSDeliveryMode();
int priority = message.getJMSPriority();
log.debug("send message with time-to-live " + ttl);
sender.send(message, deliveryMode, priority, ttl);
} else {
sender.send(message);
}
log.debug("sent message");
} catch (Throwable e) {
throw new ConnectionException(Connection.TPESYSTEM,
"Could not send the message: " + e.getMessage(), e);
}
}