|
20 | 20 | import java.io.InterruptedIOException; |
21 | 21 | import java.net.URI; |
22 | 22 | import java.security.cert.X509Certificate; |
| 23 | +import java.util.Map; |
23 | 24 | import java.util.concurrent.BlockingQueue; |
| 25 | +import java.util.concurrent.ConcurrentHashMap; |
24 | 26 | import java.util.concurrent.LinkedBlockingQueue; |
25 | 27 | import java.util.concurrent.TimeUnit; |
26 | 28 | import java.util.concurrent.atomic.AtomicBoolean; |
27 | 29 | import java.util.concurrent.atomic.AtomicLong; |
28 | 30 |
|
29 | | -import org.apache.activemq.command.ShutdownInfo; |
| 31 | +import jakarta.jms.JMSException; |
| 32 | +import org.apache.activemq.command.*; |
| 33 | +import org.apache.activemq.openwire.OpenWireFormat; |
30 | 34 | import org.apache.activemq.thread.Task; |
31 | 35 | import org.apache.activemq.thread.TaskRunner; |
32 | 36 | import org.apache.activemq.thread.TaskRunnerFactory; |
|
35 | 39 | import org.apache.activemq.transport.Transport; |
36 | 40 | import org.apache.activemq.transport.TransportDisposedIOException; |
37 | 41 | import org.apache.activemq.transport.TransportListener; |
| 42 | +import org.apache.activemq.util.ByteSequence; |
38 | 43 | import org.apache.activemq.util.IOExceptionSupport; |
39 | 44 | import org.apache.activemq.wireformat.WireFormat; |
40 | 45 | import org.slf4j.Logger; |
@@ -80,10 +85,6 @@ public void setPeer(VMTransport peer) { |
80 | 85 | @Override |
81 | 86 | public void oneway(Object command) throws IOException { |
82 | 87 |
|
83 | | - if (disposed.get()) { |
84 | | - throw new TransportDisposedIOException("Transport disposed."); |
85 | | - } |
86 | | - |
87 | 88 | if (peer == null) { |
88 | 89 | throw new IOException("Peer not connected."); |
89 | 90 | } |
@@ -161,8 +162,33 @@ public void dispatch(VMTransport transport, BlockingQueue<Object> pending, Objec |
161 | 162 | } |
162 | 163 |
|
163 | 164 | public void doDispatch(VMTransport transport, TransportListener transportListener, Object command) { |
| 165 | + if (transportListener == null) { |
| 166 | + try { |
| 167 | + throw new IOException("TransportListener not set"); |
| 168 | + } catch (IOException e) { |
| 169 | + throw new RuntimeException(e); |
| 170 | + } |
| 171 | + } |
| 172 | + |
164 | 173 | transport.receiveCounter++; |
165 | | - transportListener.onCommand(command); |
| 174 | + |
| 175 | + Object toSend = command; |
| 176 | + |
| 177 | + if (command instanceof ActiveMQMessage) { |
| 178 | + ActiveMQMessage original = (ActiveMQMessage) command; |
| 179 | + |
| 180 | + try { |
| 181 | + WireFormat wf = new OpenWireFormat(); |
| 182 | + ByteSequence data = wf.marshal(original); |
| 183 | + ActiveMQMessage copy = (ActiveMQMessage) wf.unmarshal(data); |
| 184 | + toSend = copy; |
| 185 | + } catch (IOException e) { |
| 186 | + LOG.warn("Failed to marshal/unmarshal message, sending original", e); |
| 187 | + toSend = command; |
| 188 | + } |
| 189 | + } |
| 190 | + |
| 191 | + transportListener.onCommand(toSend); |
166 | 192 | } |
167 | 193 |
|
168 | 194 | @Override |
|
0 commit comments