@Override public byte[] doGetMessageById(TransactionContext c, long storeSequenceId) throws SQLException, IOException { PreparedStatement s = null; ResultSet rs = null; try { s = c.getConnection().prepareStatement( this.statements.getFindMessageByIdStatement()); s.setLong(1, storeSequenceId); rs = s.executeQuery(); if (!rs.next()) { return null; } return getBinaryData(rs, 1); } finally { close(rs); close(s); } }
private void updateBlob(Connection connection, String findMessageByIdStatement, long sequence, byte[] data) throws SQLException, IOException { PreparedStatement s = null; ResultSet rs = null; try { s = connection.prepareStatement(statements.getFindMessageByIdStatement(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE); s.setLong(1, sequence); rs = s.executeQuery(); if (!rs.next()) { throw new IOException("Failed select blob for message: " + sequence + " in container."); } // Update the blob Blob blob = rs.getBlob(1); blob.truncate(0); blob.setBytes(1, data); rs.updateBlob(1, blob); rs.updateRow(); // Update the row with the updated blob } finally { close(rs); close(s); } }
@Override public void doAddMessage(TransactionContext c, long sequence, MessageId messageID, ActiveMQDestination destination, byte[] data, long expiration, byte priority, XATransactionId xid) throws SQLException, IOException { PreparedStatement s = null; try { // Add the Blob record. s = c.getConnection().prepareStatement(statements.getAddMessageStatement()); s.setLong(1, sequence); s.setString(2, messageID.getProducerId().toString()); s.setLong(3, messageID.getProducerSequenceId()); s.setString(4, destination.getQualifiedName()); s.setLong(5, expiration); s.setLong(6, priority); if (s.executeUpdate() != 1) { throw new IOException("Failed to add broker message: " + messageID + " in container."); } s.close(); // Select the blob record so that we can update it. updateBlob(c.getConnection(), statements.getFindMessageByIdStatement(), sequence, data); if (xid != null) { byte[] xidVal = xid.getEncodedXidBytes(); xidVal[0] = '+'; updateBlob(c.getConnection(), statements.getFindXidByIdStatement(), sequence, xidVal); } } finally { close(s); } }
public byte[] doGetMessageById(TransactionContext c, long storeSequenceId) throws SQLException, IOException { PreparedStatement s = null; ResultSet rs = null; cleanupExclusiveLock.readLock().lock(); try { s = c.getConnection().prepareStatement( this.statements.getFindMessageByIdStatement()); s.setLong(1, storeSequenceId); rs = s.executeQuery(); if (!rs.next()) { return null; } return getBinaryData(rs, 1); } finally { cleanupExclusiveLock.readLock().unlock(); close(rs); close(s); } }
@Override public byte[] doGetMessageById(TransactionContext c, long storeSequenceId) throws SQLException, IOException { PreparedStatement s = null; ResultSet rs = null; try { s = c.getConnection().prepareStatement( this.statements.getFindMessageByIdStatement()); s.setLong(1, storeSequenceId); rs = s.executeQuery(); if (!rs.next()) { return null; } return getBinaryData(rs, 1); } finally { close(rs); close(s); } }
@Override public byte[] doGetMessageById(TransactionContext c, long storeSequenceId) throws SQLException, IOException { PreparedStatement s = null; ResultSet rs = null; try { s = c.getConnection().prepareStatement( this.statements.getFindMessageByIdStatement()); s.setLong(1, storeSequenceId); rs = s.executeQuery(); if (!rs.next()) { return null; } return getBinaryData(rs, 1); } finally { close(rs); close(s); } }
@Override public byte[] doGetMessageById(TransactionContext c, long storeSequenceId) throws SQLException, IOException { PreparedStatement s = null; ResultSet rs = null; try { s = c.getConnection().prepareStatement( this.statements.getFindMessageByIdStatement()); s.setLong(1, storeSequenceId); rs = s.executeQuery(); if (!rs.next()) { return null; } return getBinaryData(rs, 1); } finally { close(rs); close(s); } }
private void updateBlob(Connection connection, String findMessageByIdStatement, long sequence, byte[] data) throws SQLException, IOException { PreparedStatement s = null; ResultSet rs = null; try { s = connection.prepareStatement(statements.getFindMessageByIdStatement(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE); s.setLong(1, sequence); rs = s.executeQuery(); if (!rs.next()) { throw new IOException("Failed select blob for message: " + sequence + " in container."); } // Update the blob Blob blob = rs.getBlob(1); blob.truncate(0); blob.setBytes(1, data); rs.updateBlob(1, blob); rs.updateRow(); // Update the row with the updated blob } finally { close(rs); close(s); } }
private void updateBlob(Connection connection, String findMessageByIdStatement, long sequence, byte[] data) throws SQLException, IOException { PreparedStatement s = null; ResultSet rs = null; try { s = connection.prepareStatement(statements.getFindMessageByIdStatement(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE); s.setLong(1, sequence); rs = s.executeQuery(); if (!rs.next()) { throw new IOException("Failed select blob for message: " + sequence + " in container."); } // Update the blob Blob blob = rs.getBlob(1); blob.truncate(0); blob.setBytes(1, data); rs.updateBlob(1, blob); rs.updateRow(); // Update the row with the updated blob } finally { close(rs); close(s); } }
private void updateBlob(Connection connection, String findMessageByIdStatement, long sequence, byte[] data) throws SQLException, IOException { PreparedStatement s = null; ResultSet rs = null; try { s = connection.prepareStatement(statements.getFindMessageByIdStatement(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE); s.setLong(1, sequence); rs = s.executeQuery(); if (!rs.next()) { throw new IOException("Failed select blob for message: " + sequence + " in container."); } // Update the blob Blob blob = rs.getBlob(1); blob.truncate(0); blob.setBytes(1, data); rs.updateBlob(1, blob); rs.updateRow(); // Update the row with the updated blob } finally { close(rs); close(s); } }
@Override public void doAddMessage(TransactionContext c, long sequence, MessageId messageID, ActiveMQDestination destination, byte[] data, long expiration, byte priority, XATransactionId xid) throws SQLException, IOException { PreparedStatement s = null; try { // Add the Blob record. s = c.getConnection().prepareStatement(statements.getAddMessageStatement()); s.setLong(1, sequence); s.setString(2, messageID.getProducerId().toString()); s.setLong(3, messageID.getProducerSequenceId()); s.setString(4, destination.getQualifiedName()); s.setLong(5, expiration); s.setLong(6, priority); if (s.executeUpdate() != 1) { throw new IOException("Failed to add broker message: " + messageID + " in container."); } s.close(); // Select the blob record so that we can update it. updateBlob(c.getConnection(), statements.getFindMessageByIdStatement(), sequence, data); if (xid != null) { byte[] xidVal = xid.getEncodedXidBytes(); xidVal[0] = '+'; updateBlob(c.getConnection(), statements.getFindXidByIdStatement(), sequence, xidVal); } } finally { close(s); } }
@Override public void doAddMessage(TransactionContext c, long sequence, MessageId messageID, ActiveMQDestination destination, byte[] data, long expiration, byte priority, XATransactionId xid) throws SQLException, IOException { PreparedStatement s = null; try { // Add the Blob record. s = c.getConnection().prepareStatement(statements.getAddMessageStatement()); s.setLong(1, sequence); s.setString(2, messageID.getProducerId().toString()); s.setLong(3, messageID.getProducerSequenceId()); s.setString(4, destination.getQualifiedName()); s.setLong(5, expiration); s.setLong(6, priority); if (s.executeUpdate() != 1) { throw new IOException("Failed to add broker message: " + messageID + " in container."); } s.close(); // Select the blob record so that we can update it. updateBlob(c.getConnection(), statements.getFindMessageByIdStatement(), sequence, data); if (xid != null) { byte[] xidVal = xid.getEncodedXidBytes(); xidVal[0] = '+'; updateBlob(c.getConnection(), statements.getFindXidByIdStatement(), sequence, xidVal); } } finally { close(s); } }
@Override public void doAddMessage(TransactionContext c, long sequence, MessageId messageID, ActiveMQDestination destination, byte[] data, long expiration, byte priority, XATransactionId xid) throws SQLException, IOException { PreparedStatement s = null; try { // Add the Blob record. s = c.getConnection().prepareStatement(statements.getAddMessageStatement()); s.setLong(1, sequence); s.setString(2, messageID.getProducerId().toString()); s.setLong(3, messageID.getProducerSequenceId()); s.setString(4, destination.getQualifiedName()); s.setLong(5, expiration); s.setLong(6, priority); if (s.executeUpdate() != 1) { throw new IOException("Failed to add broker message: " + messageID + " in container."); } s.close(); // Select the blob record so that we can update it. updateBlob(c.getConnection(), statements.getFindMessageByIdStatement(), sequence, data); if (xid != null) { byte[] xidVal = xid.getEncodedXidBytes(); xidVal[0] = '+'; updateBlob(c.getConnection(), statements.getFindXidByIdStatement(), sequence, xidVal); } } finally { close(s); } }