@Override public void storeContent() { ByteSequence bodyAsBytes = getContent(); if (bodyAsBytes == null && object != null) { try { ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); OutputStream os = bytesOut; ActiveMQConnection connection = getConnection(); if (connection != null && connection.isUseCompression()) { compressed = true; os = new DeflaterOutputStream(os); } DataOutputStream dataOut = new DataOutputStream(os); ObjectOutputStream objOut = new ObjectOutputStream(dataOut); objOut.writeObject(object); objOut.flush(); objOut.reset(); objOut.close(); setContent(bytesOut.toByteSequence()); } catch (IOException ioe) { throw new RuntimeException(ioe.getMessage(), ioe); } } }
private void copy(ActiveMQObjectMessage copy) { ActiveMQConnection connection = getConnection(); if (connection == null || !connection.isObjectMessageSerializationDefered()) { storeContent(); copy.object = null; } else { copy.object = object; } super.copy(copy); }
/** * Sets the serializable object containing this message's data. It is * important to note that an <CODE>ObjectMessage</CODE> contains a * snapshot of the object at the time <CODE>setObject()</CODE> is called; * subsequent modifications of the object will have no effect on the * <CODE>ObjectMessage</CODE> body. * * @param newObject the message's data * @throws JMSException if the JMS provider fails to set the object due to * some internal error. * @throws javax.jms.MessageFormatException if object serialization fails. * @throws javax.jms.MessageNotWriteableException if the message is in * read-only mode. */ @Override public void setObject(Serializable newObject) throws JMSException { checkReadOnlyBody(); this.object = newObject; setContent(null); ActiveMQConnection connection = getConnection(); if (connection == null || !connection.isObjectMessageSerializationDefered()) { storeContent(); } }
@Override public void onMessage(Message message) { String transport= ((ActiveMQConnection)((ActiveMQObjectMessage)message).getConnection()).getTransport().toString(); String text= ""; try { text = ((ActiveMQObjectMessage)message).getObject().toString(); } catch (JMSException e) { e.printStackTrace(); } if(Product.transportResult.containsKey(transport)){ Product.transportResult.get(transport).add(text); } else { List<String> productList=new ArrayList<>(); productList.add(text); Product.transportResult.put(transport,productList); } System.out.println("Consumer,productId:"+text+"transport:"+transport); } }
@Override public void onMessage(Message message) { String transport= ((ActiveMQConnection)((ActiveMQObjectMessage)message).getConnection()).getTransport().toString(); String text= ""; try { text = ((ActiveMQObjectMessage)message).getObject().toString(); } catch (JMSException e) { e.printStackTrace(); } if(Product.transportResult.containsKey(transport)){ Product.transportResult.get(transport).add(text); } else { List<String> productList=new ArrayList<>(); productList.add(text); Product.transportResult.put(transport,productList); } System.out.println("Consumer,productId:"+text+"transport:"+transport); } }
private void copy(ActiveMQObjectMessage copy) { ActiveMQConnection connection = getConnection(); if (connection == null || !connection.isObjectMessageSerializationDefered()) { storeContent(); copy.object = null; } else { copy.object = object; } super.copy(copy); }
@Override public void storeContent() { ByteSequence bodyAsBytes = getContent(); if (bodyAsBytes == null && object != null) { try { ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); OutputStream os = bytesOut; ActiveMQConnection connection = getConnection(); if (connection != null && connection.isUseCompression()) { compressed = true; os = new DeflaterOutputStream(os); } DataOutputStream dataOut = new DataOutputStream(os); ObjectOutputStream objOut = new ObjectOutputStream(dataOut); objOut.writeObject(object); objOut.flush(); objOut.reset(); objOut.close(); setContent(bytesOut.toByteSequence()); } catch (IOException ioe) { throw new RuntimeException(ioe.getMessage(), ioe); } } }
private void copy(ActiveMQObjectMessage copy) { ActiveMQConnection connection = getConnection(); if (connection == null || !connection.isObjectMessageSerializationDefered()) { storeContent(); copy.object = null; } else { copy.object = object; } super.copy(copy); }
@Override public void storeContent() { ByteSequence bodyAsBytes = getContent(); if (bodyAsBytes == null && object != null) { try { ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); OutputStream os = bytesOut; ActiveMQConnection connection = getConnection(); if (connection != null && connection.isUseCompression()) { compressed = true; os = new DeflaterOutputStream(os); } DataOutputStream dataOut = new DataOutputStream(os); ObjectOutputStream objOut = new ObjectOutputStream(dataOut); objOut.writeObject(object); objOut.flush(); objOut.reset(); objOut.close(); setContent(bytesOut.toByteSequence()); } catch (IOException ioe) { throw new RuntimeException(ioe.getMessage(), ioe); } } }
private void copy(ActiveMQObjectMessage copy) { ActiveMQConnection connection = getConnection(); if (connection == null || !connection.isObjectMessageSerializationDefered()) { storeContent(); copy.object = null; } else { copy.object = object; } super.copy(copy); }
@Override public void storeContent() { ByteSequence bodyAsBytes = getContent(); if (bodyAsBytes == null && object != null) { try { ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); OutputStream os = bytesOut; ActiveMQConnection connection = getConnection(); if (connection != null && connection.isUseCompression()) { compressed = true; os = new DeflaterOutputStream(os); } DataOutputStream dataOut = new DataOutputStream(os); ObjectOutputStream objOut = new ObjectOutputStream(dataOut); objOut.writeObject(object); objOut.flush(); objOut.reset(); objOut.close(); setContent(bytesOut.toByteSequence()); } catch (IOException ioe) { throw new RuntimeException(ioe.getMessage(), ioe); } } }
private void copy(ActiveMQObjectMessage copy) { ActiveMQConnection connection = getConnection(); if (connection == null || !connection.isObjectMessageSerializationDefered()) { storeContent(); copy.object = null; } else { copy.object = object; } super.copy(copy); }
public void storeContent() { ByteSequence bodyAsBytes = getContent(); if (bodyAsBytes == null && object != null) { try { ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); OutputStream os = bytesOut; ActiveMQConnection connection = getConnection(); if (connection != null && connection.isUseCompression()) { compressed = true; os = new DeflaterOutputStream(os); } DataOutputStream dataOut = new DataOutputStream(os); ObjectOutputStream objOut = new ObjectOutputStream(dataOut); objOut.writeObject(object); objOut.flush(); objOut.reset(); objOut.close(); setContent(bytesOut.toByteSequence()); } catch (IOException ioe) { throw new RuntimeException(ioe.getMessage(), ioe); } } }
/** * Sets the serializable object containing this message's data. It is * important to note that an <CODE>ObjectMessage</CODE> contains a * snapshot of the object at the time <CODE>setObject()</CODE> is called; * subsequent modifications of the object will have no effect on the * <CODE>ObjectMessage</CODE> body. * * @param newObject the message's data * @throws JMSException if the JMS provider fails to set the object due to * some internal error. * @throws javax.jms.MessageFormatException if object serialization fails. * @throws javax.jms.MessageNotWriteableException if the message is in * read-only mode. */ @Override public void setObject(Serializable newObject) throws JMSException { checkReadOnlyBody(); this.object = newObject; setContent(null); ActiveMQConnection connection = getConnection(); if (connection == null || !connection.isObjectMessageSerializationDefered()) { storeContent(); } }
/** * Sets the serializable object containing this message's data. It is * important to note that an <CODE>ObjectMessage</CODE> contains a * snapshot of the object at the time <CODE>setObject()</CODE> is called; * subsequent modifications of the object will have no effect on the * <CODE>ObjectMessage</CODE> body. * * @param newObject the message's data * @throws JMSException if the JMS provider fails to set the object due to * some internal error. * @throws javax.jms.MessageFormatException if object serialization fails. * @throws javax.jms.MessageNotWriteableException if the message is in * read-only mode. */ @Override public void setObject(Serializable newObject) throws JMSException { checkReadOnlyBody(); this.object = newObject; setContent(null); ActiveMQConnection connection = getConnection(); if (connection == null || !connection.isObjectMessageSerializationDefered()) { storeContent(); } }
/** * Sets the serializable object containing this message's data. It is * important to note that an <CODE>ObjectMessage</CODE> contains a * snapshot of the object at the time <CODE>setObject()</CODE> is called; * subsequent modifications of the object will have no effect on the * <CODE>ObjectMessage</CODE> body. * * @param newObject the message's data * @throws JMSException if the JMS provider fails to set the object due to * some internal error. * @throws javax.jms.MessageFormatException if object serialization fails. * @throws javax.jms.MessageNotWriteableException if the message is in * read-only mode. */ public void setObject(Serializable newObject) throws JMSException { checkReadOnlyBody(); this.object = newObject; setContent(null); ActiveMQConnection connection = getConnection(); if (connection == null || !connection.isObjectMessageSerializationDefered()) { storeContent(); } }
/** * Sets the serializable object containing this message's data. It is * important to note that an <CODE>ObjectMessage</CODE> contains a * snapshot of the object at the time <CODE>setObject()</CODE> is called; * subsequent modifications of the object will have no effect on the * <CODE>ObjectMessage</CODE> body. * * @param newObject the message's data * @throws JMSException if the JMS provider fails to set the object due to * some internal error. * @throws javax.jms.MessageFormatException if object serialization fails. * @throws javax.jms.MessageNotWriteableException if the message is in * read-only mode. */ @Override public void setObject(Serializable newObject) throws JMSException { checkReadOnlyBody(); this.object = newObject; setContent(null); ActiveMQConnection connection = getConnection(); if (connection == null || !connection.isObjectMessageSerializationDefered()) { storeContent(); } }