Skip to content

Commit 1e2cef5

Browse files
committed
Merge branch 'release/13.1.2'
2 parents ddb749c + 2a19bf6 commit 1e2cef5

File tree

6 files changed

+157
-4
lines changed

6 files changed

+157
-4
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<groupId>com.swiftmq</groupId>
99
<artifactId>swiftmq-client</artifactId>
10-
<version>13.1.1</version>
10+
<version>13.1.2</version>
1111

1212
<name>SwiftMQ Client</name>
1313
<description>Client for SwiftMQ Messaging System with JMS, AMQP 1.0 and file transfer over JMS.</description>

src/main/java/com/swiftmq/amqp/v100/client/Connection.java

+21
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.swiftmq.amqp.v100.client.po.POOpen;
2626
import com.swiftmq.amqp.v100.client.po.POProtocolRequest;
2727
import com.swiftmq.amqp.v100.client.po.POSendClose;
28+
import com.swiftmq.amqp.v100.generated.transport.definitions.Fields;
2829
import com.swiftmq.amqp.v100.transport.AMQPFrame;
2930
import com.swiftmq.amqp.v100.types.AMQPString;
3031
import com.swiftmq.amqp.v100.types.AMQPSymbol;
@@ -92,6 +93,7 @@ public class Connection implements ExceptionHandler {
9293
int outputBufferExtendSize = 65536;
9394
SocketFactory socketFactory = new PlainSocketFactory();
9495
ExceptionListener exceptionListener = null;
96+
Fields properties = null;
9597

9698
/**
9799
* Creates a Connection and uses SASL for authentication.
@@ -223,6 +225,23 @@ public void setOpenHostname(String openHostname) {
223225
this.openHostname = openHostname;
224226
}
225227

228+
/**
229+
* Sets the of the OpenFrame to be sent to the remote endpoint
230+
*
231+
* @param properties Fields for the OpenFrame
232+
*/
233+
public void setProperties(Fields properties) {
234+
this.properties = properties;
235+
}
236+
237+
/**
238+
* Retrieves the properties of the OpenFrame from the remote endpoint. Available after connect
239+
*
240+
* @return Fields object representing the remote properties, or null if not available
241+
*/
242+
public Fields getRemoteProperties() {
243+
return connectionDispatcher.getRemoteProperties();
244+
}
226245
/**
227246
* Sets the idle timeout. Default is Long.MAX_VALUE.
228247
* <p/>
@@ -365,6 +384,8 @@ protected ProtocolInputHandler createInputHandler() {
365384
return connectionDispatcher.getProtocolHandler();
366385
}
367386
};
387+
if (properties != null)
388+
connectionDispatcher.setProperties(properties);
368389
connectionDispatcher.setMyConnection(this);
369390
networkConnection.start();
370391
dos = new DataStreamOutputStream(networkConnection.getOutputStream());

src/main/java/com/swiftmq/amqp/v100/client/ConnectionDispatcher.java

+15-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.swiftmq.amqp.v100.generated.security.sasl.*;
2727
import com.swiftmq.amqp.v100.generated.transport.definitions.ConnectionError;
2828
import com.swiftmq.amqp.v100.generated.transport.definitions.ErrorConditionFactory;
29+
import com.swiftmq.amqp.v100.generated.transport.definitions.Fields;
2930
import com.swiftmq.amqp.v100.generated.transport.definitions.Milliseconds;
3031
import com.swiftmq.amqp.v100.generated.transport.performatives.*;
3132
import com.swiftmq.amqp.v100.transport.AMQPFrame;
@@ -76,7 +77,7 @@ public class ConnectionDispatcher
7677
POProtocolRequest protPO = null;
7778
POAuthenticate authPO = null;
7879
POOpen openPO = null;
79-
OpenFrame remoteOpen = null;
80+
volatile OpenFrame remoteOpen = null;
8081
POSendClose closePO = null;
8182
CloseFrame remoteClose = null;
8283
SaslMechanismsFrame saslMechanisms = null;
@@ -89,6 +90,7 @@ public class ConnectionDispatcher
8990
long idleTimeoutDelay = 0;
9091
SaslClient saslClient = null;
9192
volatile boolean connectionDisabled = false;
93+
Fields properties = null;
9294

9395
int maxLocalFrameSize = Integer.MAX_VALUE;
9496
int maxRemoteFrameSize = Integer.MAX_VALUE;
@@ -133,6 +135,16 @@ public int getMaxFrameSize() {
133135
return Math.max(512, Math.min(maxLocalFrameSize, maxRemoteFrameSize));
134136
}
135137

138+
public void setProperties(Fields properties) {
139+
this.properties = properties;
140+
}
141+
142+
public Fields getRemoteProperties() {
143+
if (remoteOpen != null)
144+
return remoteOpen.getProperties();
145+
return null;
146+
}
147+
136148
public void setSaslActive(boolean saslActive) {
137149
this.saslActive = saslActive;
138150
}
@@ -317,6 +329,8 @@ public void visit(POOpen po) {
317329
OpenFrame openFrame = new OpenFrame(0);
318330
openFrame.setContainerId(new AMQPString(po.getContainerId()));
319331
openFrame.setChannelMax(new AMQPUnsignedShort(po.getMaxChannel()));
332+
if (properties != null)
333+
openFrame.setProperties(properties);
320334
if (myConnection.getOpenHostname() == null)
321335
openFrame.setHostname(new AMQPString(remoteHostname));
322336
else

src/main/java/com/swiftmq/client/thread/DefaultPoolManager.java

+11
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.concurrent.locks.ReentrantReadWriteLock;
2424

2525
public class DefaultPoolManager extends PoolManager {
26+
public static final String PROP_JAC_ACTIVE = "swiftmq.jac.active";
2627
public static final String PROP_CONNECTOR_POOL_MIN_THREADS = "swiftmq.pool.connector.threads.min";
2728
public static final String PROP_CONNECTOR_POOL_MAX_THREADS = "swiftmq.pool.connector.threads.max";
2829
public static final String PROP_CONNECTOR_POOL_PRIO = "swiftmq.pool.connector.priority";
@@ -45,6 +46,16 @@ public class DefaultPoolManager extends PoolManager {
4546
ThreadPool connectionPool = null;
4647
ThreadPool sessionPool = null;
4748
ThreadPool connectorPool = null;
49+
boolean JAC_ACTIVE = System.getProperty(PROP_JAC_ACTIVE, "false").equals("true");
50+
51+
public DefaultPoolManager() {
52+
if (JAC_ACTIVE) {
53+
ThreadPool pool = new IVMTaskScheduler();
54+
connectionPool = pool;
55+
sessionPool = pool;
56+
connectorPool = pool;
57+
}
58+
}
4859

4960
ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
5061

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package com.swiftmq.client.thread;
2+
3+
import com.swiftmq.swiftlet.SwiftletManager;
4+
import com.swiftmq.swiftlet.threadpool.AsyncTask;
5+
import com.swiftmq.swiftlet.threadpool.ThreadPool;
6+
import com.swiftmq.swiftlet.threadpool.ThreadpoolSwiftlet;
7+
import com.swiftmq.swiftlet.threadpool.event.FreezeCompletionListener;
8+
9+
public class IVMTaskScheduler implements ThreadPool {
10+
11+
ThreadpoolSwiftlet threadpoolSwiftlet = null;
12+
13+
public IVMTaskScheduler() {
14+
threadpoolSwiftlet = (ThreadpoolSwiftlet) SwiftletManager.getInstance().getSwiftlet("sys$threadpool");
15+
if (threadpoolSwiftlet == null)
16+
System.err.println("[" + this + "] Failed to get ThreadpoolSwiftlet");
17+
else
18+
System.out.println("[" + this + "] App uses virtual threads, scheduled in: adhocvirtual");
19+
}
20+
21+
/**
22+
* Closes the pool.
23+
* Internal use only.
24+
*/
25+
@Override
26+
public void close() {
27+
28+
}
29+
30+
/**
31+
* Returns the pool name.
32+
*
33+
* @return pool name.
34+
*/
35+
@Override
36+
public String getPoolName() {
37+
return toString();
38+
}
39+
40+
/**
41+
* Returns the number of currently idling threads.
42+
* Used from management tools only.
43+
*
44+
* @return number of idling threads.
45+
*/
46+
@Override
47+
public int getNumberIdlingThreads() {
48+
return 0;
49+
}
50+
51+
/**
52+
* Returns the number of currently running threads.
53+
* Used from management tools only.
54+
*
55+
* @return number of running threads.
56+
*/
57+
@Override
58+
public int getNumberRunningThreads() {
59+
return 0;
60+
}
61+
62+
/**
63+
* Dispatch a task into the pool.
64+
*
65+
* @param asyncTask the task to dispatch.
66+
*/
67+
@Override
68+
public void dispatchTask(AsyncTask asyncTask) {
69+
threadpoolSwiftlet.runAsync(asyncTask, true);
70+
}
71+
72+
/**
73+
* Freezes this pool. That is, the current running tasks are completed but
74+
* no further tasks will be scheduled until unfreeze() is called. It is possible
75+
* to dispatch tasks during freeze. However, these will be executed after unfreeze()
76+
* is called.
77+
*
78+
* @param listener will be called when the pool is freezed.
79+
*/
80+
@Override
81+
public void freeze(FreezeCompletionListener listener) {
82+
83+
}
84+
85+
/**
86+
* Unfreezes this pool.
87+
*/
88+
@Override
89+
public void unfreeze() {
90+
91+
}
92+
93+
/**
94+
* Stops the pool.
95+
* Internal use only.
96+
*/
97+
@Override
98+
public void stop() {
99+
100+
}
101+
102+
@Override
103+
public String toString() {
104+
return IVMTaskScheduler.class.getSimpleName();
105+
}
106+
}

src/main/java/com/swiftmq/jms/v750/MessageConsumerImpl.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import javax.jms.IllegalStateException;
3434
import javax.jms.*;
3535
import java.util.List;
36+
import java.util.concurrent.TimeUnit;
3637
import java.util.concurrent.atomic.AtomicBoolean;
3738
import java.util.concurrent.atomic.AtomicInteger;
3839
import java.util.concurrent.locks.Lock;
@@ -371,9 +372,9 @@ Message receiveMessage(boolean block, long timeout) throws JMSException {
371372
} else {
372373
long to = timeout;
373374
do {
374-
long startWait = System.currentTimeMillis();
375+
long startWait = System.nanoTime();
375376
waiter.doWait(to);
376-
long delta = System.currentTimeMillis() - startWait;
377+
long delta = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startWait);
377378
to -= delta;
378379
}
379380
while (to > 0 && messageCache.getSize() == 0 && fillCachePending.get() && !cancelled.get() && !isClosed());

0 commit comments

Comments
 (0)