Skip to content

Commit e4096b9

Browse files
authored
Make 'eval' work in callback function (#94)
* Mechanical code checks * File is nor required anymore * Bump version * Update to activemq 5.14.1 * Extended logging : write stack traces where potentially needed * Fix typo * UpdUpdate to activemq 5.14.1 * Final fix for #93
1 parent 832a63a commit e4096b9

21 files changed

+60
-160
lines changed

build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ exist.dir=../exist/
33

44
# Extension details
55
module.name=messaging-replication
6-
module.version=0.9.12
6+
module.version=0.9.13
77
module.title=Messaging and Replication
88

99
# Build instructions

config/library/exist.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<package xmlns="http://exist-db.org/ns/expath-pkg">
33
<jar>exist-messaging-replication-@[email protected]</jar>
4-
<jar>activemq-client-5.14.0.jar</jar>
5-
<jar>activemq-jms-pool-5.14.0.jar</jar>
6-
<jar>activemq-pool-5.14.0.jar</jar>
4+
<jar>activemq-client-5.14.1.jar</jar>
5+
<jar>activemq-jms-pool-5.14.1.jar</jar>
6+
<jar>activemq-pool-5.14.1.jar</jar>
77
<jar>geronimo-j2ee-management_1.1_spec-1.0.1.jar</jar>
88
<jar>geronimo-jms_1.1_spec-1.1.1.jar</jar>
99
<jar>hawtbuf-1.11.jar</jar>

ivy.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<dependencies>
88

99
<!-- ActiveMQ client -->
10-
<dependency org="org.apache.activemq" name="activemq-client" rev="5.14.0" conf="*->*">
10+
<dependency org="org.apache.activemq" name="activemq-client" rev="5.14.1" conf="*->*">
1111
<exclude module="ant"/>
1212
<exclude module="slf4j-api"/>
1313
<exclude module="commons-net"/>
@@ -19,10 +19,10 @@
1919
</dependency>
2020

2121
<!-- ActiveMQ pool -->
22-
<dependency org="org.apache.activemq" name="activemq-pool" rev="5.14.0" conf="*->*" transitive="false"/>
22+
<dependency org="org.apache.activemq" name="activemq-pool" rev="5.14.1" conf="*->*" transitive="false"/>
2323

2424
<!-- ActiveMQ jms pool -->
25-
<dependency org="org.apache.activemq" name="activemq-jms-pool" rev="5.14.0" conf="*->*" transitive="false"/>
25+
<dependency org="org.apache.activemq" name="activemq-jms-pool" rev="5.14.1" conf="*->*" transitive="false"/>
2626

2727
<!-- Additional dependancy -->
2828
<dependency org="org.apache.commons" name="commons-pool2" rev="2.4.2" conf="*->*" transitive="false"/>

java/src/org/exist/jms/messaging/MessagingJmsListener.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class MessagingJmsListener extends eXistMessagingListener {
6868
private Subject subject;
6969
private Report report = null;
7070

71-
// private Session session;
71+
// private Session session;
7272
private int receiverID = -1;
7373

7474

@@ -83,7 +83,7 @@ public class MessagingJmsListener extends eXistMessagingListener {
8383
public MessagingJmsListener(final Subject subject, final FunctionReference functionReference, final Sequence functionParams, final XQueryContext xqueryContext) {
8484
super();
8585
this.functionReference = functionReference;
86-
this.xqueryContext = xqueryContext;
86+
this.xqueryContext = xqueryContext.copyContext();
8787
this.functionParams = functionParams;
8888
this.report = getReport();
8989
this.subject = subject;
@@ -93,7 +93,10 @@ public MessagingJmsListener(final Subject subject, final FunctionReference funct
9393
public void onMessage(final Message msg) {
9494

9595
// Make a copy, just in case
96-
functionReference.setContext(xqueryContext.copyContext());
96+
XQueryContext copyContext = xqueryContext.copyContext();
97+
98+
// Set new context to function reference
99+
functionReference.setContext(copyContext);
97100

98101
receiverID = getReceiverID();
99102

@@ -153,7 +156,7 @@ public void onMessage(final Message msg) {
153156

154157
// Done
155158
if (LOG.isDebugEnabled()) {
156-
LOG.debug("Reciever={} : Function returned %s", receiverID, result.getStringValue());
159+
LOG.debug("Receiver={} : Function returned %s", receiverID, result.getStringValue());
157160
}
158161

159162
// Acknowledge processing
@@ -167,6 +170,9 @@ public void onMessage(final Message msg) {
167170
}
168171

169172
} catch (final Throwable ex) {
173+
174+
LOG.error(ex.getMessage(), ex);
175+
170176
report.addListenerError(ex);
171177
LOG.error(String.format("%s (Receiver=%s)", ex.getMessage(), receiverID), ex);
172178

@@ -193,7 +199,7 @@ public void onMessage(final Message msg) {
193199
/**
194200
* Convert JMS message into a sequence of data.
195201
*
196-
* @param msg The JMS message object
202+
* @param msg The JMS message object
197203
* @return Sequence representing the JMS message
198204
* @throws IOException An internal IO error occurred.
199205
* @throws XPathException An eXist-db object could not be handled.

java/src/org/exist/jms/replication/publish/JMSMessageSender.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public class JMSMessageSender implements MessageSender {
4848
/**
4949
* Constructor
5050
*
51-
* @param parameters Set of (Key,value) parameters for setting JMS routing
52-
* instructions, like java.naming.* , destination and connection factory.
51+
* @param params Set of (Key,value) parameters for setting JMS routing
52+
* instructions, like java.naming.* , destination and connection factory.
5353
*/
5454
JMSMessageSender(final Map<String, List<?>> params) {
5555
parameters.setMultiValueParameters(params);

java/src/org/exist/jms/replication/shared/MessageHelper.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ public class MessageHelper {
7676
/**
7777
* Serialize document to byte array as gzipped document.
7878
*
79-
* @param broker
80-
* @param document
81-
* @return document as bytes
82-
* @throws IOException
79+
* @param broker The broker
80+
* @param document Document to compress
81+
* @return document as array of bytes
82+
* @throws IOException When the
8383
*/
8484
public static byte[] gzipSerialize(final DBBroker broker, final DocumentImpl document) throws IOException {
8585

@@ -114,7 +114,7 @@ public static byte[] gzipSerialize(final DBBroker broker, final DocumentImpl doc
114114
} catch (final Throwable e) {
115115
payload = new byte[0];
116116
System.gc(); // recover from out of memory exception
117-
LOG.error(e);
117+
LOG.error(e.getMessage(), e);
118118
throw new IOException(String.format("Error while serializing XML document: %s", e.getMessage()), e);
119119
}
120120

@@ -140,7 +140,7 @@ public static byte[] gzipSerialize(final DBBroker broker, final DocumentImpl doc
140140
} catch (final Throwable e) {
141141
payload = new byte[0];
142142
System.gc(); // recover from out of memory exception
143-
LOG.error(e);
143+
LOG.error(e.getMessage(), e);
144144
throw new IOException(String.format("Error while serializing binary document: %s", e.getMessage()), e);
145145
}
146146
}

java/src/org/exist/jms/replication/shared/ReplicationGuard.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@
2727
*/
2828
public class ReplicationGuard {
2929

30-
private static volatile ReplicationGuard instance = null;
3130
private final static Logger LOGGER = LogManager.getLogger(ReplicationGuard.class);
32-
31+
private static volatile ReplicationGuard instance = null;
3332
boolean replicationEnabled = true;
3433

3534
private ReplicationGuard() {
@@ -51,14 +50,14 @@ public static ReplicationGuard getInstance() {
5150

5251
}
5352

54-
public void setReplicationEnabled(boolean newStatus){
53+
public boolean getReplicationEnabled() {
54+
return this.replicationEnabled;
55+
}
5556

56-
LOGGER.info("Replication is switched {}", newStatus ? "ON" : "OFF");
57+
public void setReplicationEnabled(final boolean newStatus) {
5758

58-
this.replicationEnabled=newStatus;
59-
}
59+
LOGGER.info("Replication is switched {}", newStatus ? "ON" : "OFF");
6060

61-
public boolean getReplicationEnabled(){
62-
return this.replicationEnabled;
61+
this.replicationEnabled = newStatus;
6362
}
6463
}

java/src/org/exist/jms/replication/subscribe/ReplicationJmsListener.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.apache.commons.lang3.StringUtils;
2525
import org.apache.logging.log4j.LogManager;
2626
import org.apache.logging.log4j.Logger;
27-
import org.exist.EXistException;
2827
import org.exist.collections.Collection;
2928
import org.exist.collections.IndexInfo;
3029
import org.exist.dom.persistent.DocumentImpl;
@@ -33,9 +32,6 @@
3332
import org.exist.security.Account;
3433
import org.exist.security.Group;
3534
import org.exist.security.Permission;
36-
import org.exist.security.PermissionDeniedException;
37-
import org.exist.security.internal.aider.GroupAider;
38-
import org.exist.security.internal.aider.UserAider;
3935
import org.exist.storage.BrokerPool;
4036
import org.exist.storage.DBBroker;
4137
import org.exist.storage.lock.Lock;
@@ -347,7 +343,7 @@ private void createUpdateDocument(final eXistMessage em) {
347343
collection = getOrCreateCollection(colURI, userName, groupName, Optional.of(Permission.DEFAULT_COLLECTION_PERM), null);
348344

349345
} catch (final MessageReceiveException e) {
350-
LOG.error(e.getMessage());
346+
LOG.error(e.getMessage(), e);
351347
throw e;
352348
} catch (final Throwable t) {
353349
if (LOG.isDebugEnabled()) {
@@ -534,7 +530,7 @@ private void updateMetadataDocument(final eXistMessage em) {
534530
txn.commit();
535531

536532
} catch (final Throwable e) {
537-
LOG.error(e);
533+
LOG.error(e.getMessage(), e);
538534
throw new MessageReceiveException(e.getMessage(), e);
539535

540536
} finally {
@@ -795,7 +791,7 @@ private void relocateDocument(final eXistMessage em, final boolean keepDocument)
795791
txnManager.commit(txn);
796792

797793
} catch (final Throwable e) {
798-
LOG.error(e);
794+
LOG.error(e.getMessage(), e);
799795
throw new MessageReceiveException(e.getMessage(), e);
800796

801797
} finally {
@@ -847,7 +843,7 @@ private void relocateCollection(final eXistMessage em, final boolean keepCollect
847843
txn.commit();
848844

849845
} catch (final Throwable e) {
850-
LOG.error(e);
846+
LOG.error(e.getMessage(), e);
851847
throw new MessageReceiveException(e.getMessage());
852848

853849
} finally {
@@ -911,7 +907,7 @@ private void updateMetadataCollection(final eXistMessage em) {
911907
txn.commit();
912908

913909
} catch (final Throwable e) {
914-
LOG.error(e);
910+
LOG.error(e.getMessage(), e);
915911
throw new MessageReceiveException(e.getMessage());
916912

917913
} finally {

java/src/org/exist/jms/replication/subscribe/UserGroupHelper.java

Lines changed: 0 additions & 100 deletions
This file was deleted.

java/src/org/exist/jms/send/Sender.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public NodeImpl send(final JmsConfiguration jmsConfig, final JmsMessagePropertie
174174
return createReport(message, producer, jmsConfig);
175175

176176
} catch (final Throwable ex) {
177-
LOG.error(ex);
177+
LOG.error(ex.getMessage(), ex);
178178
throw new XPathException(ex.getMessage());
179179

180180
} finally {
@@ -197,7 +197,7 @@ private ConnectionFactory getConnectionFactoryInstance(final javax.naming.Contex
197197
final ConnectionFactory retVal;
198198

199199
// Use pooling when
200-
final String poolValue = jmsConfig.getProperty(EXIST_CONNECTION_POOL,"activemq");
200+
final String poolValue = jmsConfig.getProperty(EXIST_CONNECTION_POOL, "activemq");
201201
if (StringUtils.isNotBlank(poolValue)) {
202202

203203
// Get URL to broker

0 commit comments

Comments
 (0)