select = _connection.prepareStatement(
"select * from " + MESSAGE_TABLE + " where message_id = ?");
select.setString(1, messageId);
set = select.executeQuery();
if (!set.next()) {
throw new PersistenceException(
"Message not found, JMSMessageID=" + messageId);
}
String correlationId = set.getString("correlation_id");
int deliveryMode = set.getInt("delivery_mode");
long destinationId = set.getLong("destination_id");
long expiration = set.getLong("expiration");
int priority = set.getInt("priority");
boolean redelivered = set.getBoolean("redelivered");
long replyToId = set.getLong("reply_to_id");
long timestamp = set.getLong("timestamp");
String type = set.getString("type");
Destination destination = _destinations.get(destinationId);
message.setJMSMessageID(messageId);
message.setJMSCorrelationID(correlationId);
message.setJMSDeliveryMode(deliveryMode);
message.setJMSDestination(destination);
message.setJMSExpiration(expiration);
message.setJMSPriority(priority);
message.setJMSRedelivered(redelivered);
if (replyToId != 0) {
Destination replyTo = _destinations.get(replyToId);
message.setJMSReplyTo(replyTo);
}
message.setJMSTimestamp(timestamp);
message.setJMSType(type);
Blob blob = set.getBlob("body");
Object body;
try {
body = deserialize(blob);
} catch (Exception exception) {
throw new PersistenceException(
"Failed to deserialize message body, JMSMessageID="
+ messageId, exception);
}
setBody(body, message);
} catch (SQLException exception) {
throw new PersistenceException(
"Failed to populate message, JMSMessageID="
+ messageId, exception);
} finally {
SQLHelper.close(set);
SQLHelper.close(select);