I got an error(Agent configuration for 'a1' has no configfilters) when I use flume 1.9 to transfer the data from kafka to HDFS, but no other error or info were reported.
The source I used is KafkaSource, sink is file sink.
Interceptor I used is self-define which I will show bolow.
Agent configuration for 'a1' has no configfilters.
the logger info is below. differ from other question, the
16 Aug 2022 11:45:27,600 WARN [conf-file-poller-0] (org.apache.flume.conf.FlumeConfiguration$AgentConfiguration.validateConfigFilterSet:623) - Agent configuration for 'a1' has no configfilters.
16 Aug 2022 11:45:27,623 INFO [conf-file-poller-0] (org.apache.flume.conf.FlumeConfiguration.validateConfiguration:163) - Post-validation flume configuration contains configuration for agents: [a1]
16 Aug 2022 11:45:27,624 INFO [conf-file-poller-0] (org.apache.flume.node.AbstractConfigurationProvider.loadChannels:151) - Creating channels
16 Aug 2022 11:45:27,628 INFO [conf-file-poller-0] (org.apache.flume.channel.DefaultChannelFactory.create:42) - Creating instance of channel c1 type file
16 Aug 2022 11:45:27,642 INFO [conf-file-poller-0] (org.apache.flume.node.AbstractConfigurationProvider.loadChannels:205) - Created channel c1
16 Aug 2022 11:45:27,643 INFO [conf-file-poller-0] (org.apache.flume.source.DefaultSourceFactory.create:41) - Creating instance of source r1, type org.apache.flume.source.kafka.KafkaSource
16 Aug 2022 11:45:27,655 INFO [conf-file-poller-0] (org.apache.flume.sink.DefaultSinkFactory.create:42) - Creating instance of sink: k1, type: hdfs
16 Aug 2022 11:45:27,786 INFO [conf-file-poller-0] (org.apache.flume.node.AbstractConfigurationProvider.getConfiguration:120) - Channel c1 connected to [r1, k1]
16 Aug 2022 11:45:27,787 INFO [conf-file-poller-0] (org.apache.flume.node.Application.startAllComponents:162) - Starting new configuration:{ sourceRunners:{r1=PollableSourceRunner: { source:org.apache.flume.source.kafka.KafkaSource{name:r1,state:IDLE} counterGroup:{ name:null counters:{} } }} sinkRunners:{k1=SinkRunner: { policy:org.apache.flume.sink.DefaultSinkProcessor#2aa62fb9 counterGroup:{ name:null counters:{} } }} channels:{c1=FileChannel c1 { dataDirs: [/opt/module/flume/data/ranqi/behavior2] }} }
16 Aug 2022 11:45:27,788 INFO [conf-file-poller-0] (org.apache.flume.node.Application.startAllComponents:169) - Starting Channel c1
16 Aug 2022 11:45:27,790 INFO [conf-file-poller-0] (org.apache.flume.node.Application.startAllComponents:184) - Waiting for channel: c1 to start. Sleeping for 500 ms
16 Aug 2022 11:45:27,790 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.FileChannel.start:278) - Starting FileChannel c1 { dataDirs: [/opt/module/flume/data/ranqi/behavior2] }...
16 Aug 2022 11:45:27,833 INFO [lifecycleSupervisor-1-0] (org.apache.flume.instrumentation.MonitoredCounterGroup.register:119) - Monitored counter group for type: CHANNEL, name: c1: Successfully registered new MBean.
16 Aug 2022 11:45:27,833 INFO [lifecycleSupervisor-1-0] (org.apache.flume.instrumentation.MonitoredCounterGroup.start:95) - Component type: CHANNEL, name: c1 started
16 Aug 2022 11:45:27,839 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.Log.<init>:356) - Encryption is not enabled
16 Aug 2022 11:45:27,840 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.Log.replay:406) - Replay started
16 Aug 2022 11:45:27,845 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.Log.replay:418) - Found NextFileID 3, from [/opt/module/flume/data/ranqi/behavior2/log-3, /opt/module/flume/data/ranqi/behavior2/log-2]
16 Aug 2022 11:45:27,851 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.EventQueueBackingStoreFileV3.<init>:55) - Starting up with /opt/module/flume/checkpoint/ranqi/behavior2/checkpoint and /opt/module/flume/checkpoint/ranqi/behavior2/checkpoint.meta
16 Aug 2022 11:45:27,851 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.EventQueueBackingStoreFileV3.<init>:59) - Reading checkpoint metadata from /opt/module/flume/checkpoint/ranqi/behavior2/checkpoint.meta
16 Aug 2022 11:45:27,906 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.FlumeEventQueue.<init>:115) - QueueSet population inserting 0 took 0
16 Aug 2022 11:45:27,908 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.Log.replay:457) - Last Checkpoint Mon Aug 15 17:11:08 CST 2022, queue depth = 0
16 Aug 2022 11:45:27,918 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.Log.doReplay:542) - Replaying logs with v2 replay logic
16 Aug 2022 11:45:27,919 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.ReplayHandler.replayLog:249) - Starting replay of [/opt/module/flume/data/ranqi/behavior2/log-2, /opt/module/flume/data/ranqi/behavior2/log-3]
16 Aug 2022 11:45:27,920 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.ReplayHandler.replayLog:262) - Replaying /opt/module/flume/data/ranqi/behavior2/log-2
16 Aug 2022 11:45:27,925 INFO [lifecycleSupervisor-1-0] (org.apache.flume.tools.DirectMemoryUtils.getDefaultDirectMemorySize:112) - Unable to get maxDirectMemory from VM: NoSuchMethodException: sun.misc.VM.maxDirectMemory(null)
16 Aug 2022 11:45:27,926 INFO [lifecycleSupervisor-1-0] (org.apache.flume.tools.DirectMemoryUtils.allocate:48) - Direct Memory Allocation: Allocation = 1048576, Allocated = 0, MaxDirectMemorySize = 1908932608, Remaining = 1908932608
16 Aug 2022 11:45:27,982 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.LogFile$SequentialReader.skipToLastCheckpointPosition:660) - Checkpoint for file(/opt/module/flume/data/ranqi/behavior2/log-2) is: 1660554206424, which is beyond the requested checkpoint time: 1660555388025 and position 0
16 Aug 2022 11:45:27,982 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.ReplayHandler.replayLog:262) - Replaying /opt/module/flume/data/ranqi/behavior2/log-3
16 Aug 2022 11:45:27,983 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.LogFile$SequentialReader.skipToLastCheckpointPosition:658) - fast-forward to checkpoint position: 273662090
16 Aug 2022 11:45:27,983 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.LogFile$SequentialReader.next:683) - Encountered EOF at 273662090 in /opt/module/flume/data/ranqi/behavior2/log-3
16 Aug 2022 11:45:27,983 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.ReplayHandler.replayLog:345) - read: 0, put: 0, take: 0, rollback: 0, commit: 0, skip: 0, eventCount:0
16 Aug 2022 11:45:27,984 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.FlumeEventQueue.replayComplete:417) - Search Count = 0, Search Time = 0, Copy Count = 0, Copy Time = 0
16 Aug 2022 11:45:27,988 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.Log.replay:505) - Rolling /opt/module/flume/data/ranqi/behavior2
16 Aug 2022 11:45:27,988 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.Log.roll:990) - Roll start /opt/module/flume/data/ranqi/behavior2
16 Aug 2022 11:45:27,989 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.LogFile$Writer.<init>:220) - Opened /opt/module/flume/data/ranqi/behavior2/log-4
16 Aug 2022 11:45:27,996 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.Log.roll:1006) - Roll end
16 Aug 2022 11:45:27,996 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.EventQueueBackingStoreFile.beginCheckpoint:230) - Start checkpoint for /opt/module/flume/checkpoint/ranqi/behavior2/checkpoint, elements to sync = 0
16 Aug 2022 11:45:28,000 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.EventQueueBackingStoreFile.checkpoint:255) - Updating checkpoint metadata: logWriteOrderID: 1660621527859, queueSize: 0, queueHead: 557327
16 Aug 2022 11:45:28,008 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.Log.writeCheckpoint:1065) - Updated checkpoint for file: /opt/module/flume/data/ranqi/behavior2/log-4 position: 0 logWriteOrderID: 1660621527859
16 Aug 2022 11:45:28,008 INFO [lifecycleSupervisor-1-0] (org.apache.flume.channel.file.FileChannel.start:289) - Queue Size after replay: 0 [channel=c1]
16 Aug 2022 11:45:28,290 INFO [conf-file-poller-0] (org.apache.flume.node.Application.startAllComponents:196) - Starting Sink k1
16 Aug 2022 11:45:28,291 INFO [conf-file-poller-0] (org.apache.flume.node.Application.startAllComponents:207) - Starting Source r1
16 Aug 2022 11:45:28,292 INFO [lifecycleSupervisor-1-1] (org.apache.flume.instrumentation.MonitoredCounterGroup.register:119) - Monitored counter group for type: SINK, name: k1: Successfully registered new MBean.
16 Aug 2022 11:45:28,292 INFO [lifecycleSupervisor-1-1] (org.apache.flume.instrumentation.MonitoredCounterGroup.start:95) - Component type: SINK, name: k1 started
16 Aug 2022 11:45:28,292 INFO [lifecycleSupervisor-1-4] (org.apache.flume.source.kafka.KafkaSource.doStart:524) - Starting org.apache.flume.source.kafka.KafkaSource{name:r1,state:IDLE}...
flume agent start use shell command below.
#!/bin/bash
case $1 in
"start")
echo " --------start flume-------"
ssh hadoop104 "nohup /opt/module/flume/bin/flume-ng agent -n a1 -c /opt/module/flume/conf -f /opt/module/flume/job/ranqi/ranqi_kafka_to_hdfs_db.conf >/dev/null 2>&1 &"
;;
"stop")
echo " --------stop flume-------"
ssh hadoop104 "ps -ef | grep ranqi_kafka_to_hdfs_db.conf | grep -v grep |awk '{print \$2}' | xargs -n1 kill"
;;
esac
flume config is below.
a1.sources = r1
a1.channels = c1
a1.sinks = k1
a1.sources.r1.type = org.apache.flume.source.kafka.KafkaSource
a1.sources.r1.batchSize = 5000
a1.sources.r1.batchDurationMillis = 2000
a1.sources.r1.kafka.bootstrap.servers = hadoop102:9092,hadoop103:9092
a1.sources.r1.kafka.topics = copy_1015
a1.sources.r1.kafka.consumer.group.id = flume
a1.sources.r1.setTopicHeader = true
a1.sources.r1.topicHeader = topic
a1.sources.r1.interceptors = i1
a1.sources.r1.interceptors.i1.type = com.atguigu.flume.interceptor.ranqi.ranqiTimestampInterceptor$Builder
a1.channels.c1.type = file
a1.channels.c1.checkpointDir = /opt/module/flume/checkpoint/ranqi/behavior2
a1.channels.c1.dataDirs = /opt/module/flume/data/ranqi/behavior2/
a1.channels.c1.maxFileSize = 2146435071
a1.channels.c1.capacity = 1123456
a1.channels.c1.keep-alive = 6
## sink1
a1.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.path = /origin_data/ranqi/db/%{topic}_inc/%Y-%m-%d
a1.sinks.k1.hdfs.filePrefix = db
a1.sinks.k1.hdfs.round = false
a1.sinks.k1.hdfs.rollInterval = 10
a1.sinks.k1.hdfs.rollSize = 134217728
a1.sinks.k1.hdfs.rollCount = 0
a1.sinks.k1.hdfs.fileType = CompressedStream
a1.sinks.k1.hdfs.codeC = gzip
## 拼装
a1.sources.r1.channels = c1
a1.sinks.k1.channel= c1
ranqiTimestampInterceptor class I defined is below, which in flume/lib.
package com.atguigu.flume.interceptor.ranqi;
import com.alibaba.fastjson.JSONObject;
import com.atguigu.flume.interceptor.db.TimestampInterceptor;
import org.apache.flume.Context;
import org.apache.flume.Event;
import org.apache.flume.interceptor.Interceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
public class ranqiTimestampInterceptor implements Interceptor {
public static String dateToStamp(String s) throws ParseException {
String res;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = simpleDateFormat.parse(s);
long ts = date.getTime();
res = String.valueOf(ts);
return res;
}
#Override
public void initialize() {
}
private final static Logger logger = LoggerFactory.getLogger(ranqiTimestampInterceptor.class);
#Override
public Event intercept(Event event) {
byte[] body = event.getBody();
Long createDate ;
String time = new String();
String log = new String(body, StandardCharsets.UTF_8);
JSONObject jsonObject = JSONObject.parseObject(log);
// logger.info(log);
logger.info(String.valueOf(jsonObject));
JSONObject data = jsonObject.getObject("data", JSONObject.class);
if(data.containsKey("createDate") && data.getLong("createDate") != null){
createDate = data.getLong("createDate");
try {
createDate = Long.valueOf(dateToStamp(String.valueOf(createDate)));
time = String.valueOf(createDate);
} catch (ParseException e) {
e.printStackTrace();
}
finally {
Long ts = jsonObject.getLong("ts");
time = String.valueOf(ts);
}
}else{
Long ts = jsonObject.getLong("ts");
time = String.valueOf(ts);
}
System.out.println(time);
logger.info(time);
Map<String, String> headers = event.getHeaders();
headers.put("timestamp",time);
return event;
}
#Override
public List<Event> intercept(List<Event> list) {
for (Event event : list) {
intercept(event);
}
return list;
}
#Override
public void close() {
}
public static class Builder implements Interceptor.Builder{
#Override
public Interceptor build() {
return new TimestampInterceptor();
}
#Override
public void configure(Context context) {
}
}
}
.
I've been using a lot python tika to exctract text from some pdfs. Suddenly Tika doesn't work any more with the following code and similar:
from tika import parser
document = parser.from_file("prova.pdf")['content']
or
from tika import parser
parser.from_file("C:/Users/Daniele/Desktop/progetto_tesi_magistrale/prova.pdf")['content']
and every time I get this error:
2021-02-23 10:57:36,244 [MainThread ] [INFO ] Retrieving C:\Program Files\tika-server-1.24.1.jar to C:\Users\Daniele\AppData\Local\Temp\tika-server.jar.
---------------------------------------------------------------------------
URLError Traceback (most recent call last)
~\anaconda3\lib\site-packages\tika\tika.py in getRemoteJar(urlOrPath, destPath)
797 try:
--> 798 urlretrieve(urlOrPath, destPath)
799 except IOError:
~\anaconda3\lib\urllib\request.py in urlretrieve(url, filename, reporthook, data)
246
--> 247 with contextlib.closing(urlopen(url, data)) as fp:
248 headers = fp.info()
~\anaconda3\lib\urllib\request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
221 opener = _opener
--> 222 return opener.open(url, data, timeout)
223
~\anaconda3\lib\urllib\request.py in open(self, fullurl, data, timeout)
524 sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method())
--> 525 response = self._open(req, data)
526
~\anaconda3\lib\urllib\request.py in _open(self, req, data)
546
--> 547 return self._call_chain(self.handle_open, 'unknown',
548 'unknown_open', req)
~\anaconda3\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args)
501 func = getattr(handler, meth_name)
--> 502 result = func(*args)
503 if result is not None:
~\anaconda3\lib\urllib\request.py in unknown_open(self, req)
1420 type = req.type
-> 1421 raise URLError('unknown url type: %s' % type)
1422
URLError: <urlopen error unknown url type: c>
During handling of the above exception, another exception occurred:
URLError Traceback (most recent call last)
<ipython-input-4-5aa5aa48deec> in <module>
1 from tika import parser
2
----> 3 document = parser.from_file("prova.pdf")['content']
4 #import tika
5 #from tika import parser
~\anaconda3\lib\site-packages\tika\parser.py in from_file(filename, serverEndpoint, service, xmlContent, headers, config_path, requestOptions)
38 '''
39 if not xmlContent:
---> 40 output = parse1(service, filename, serverEndpoint, headers=headers, config_path=config_path, requestOptions=requestOptions)
41 else:
42 output = parse1(service, filename, serverEndpoint, services={'meta': '/meta', 'text': '/tika', 'all': '/rmeta/xml'},
~\anaconda3\lib\site-packages\tika\tika.py in parse1(option, urlOrPath, serverEndpoint, verbose, tikaServerJar, responseMimeType, services, rawResponse, headers, config_path, requestOptions)
334 headers.update({'Accept': responseMimeType, 'Content-Disposition': make_content_disposition_header(path.encode('utf-8') if type(path) is unicode_string else path)})
335 with urlOrPath if _is_file_object(urlOrPath) else open(path, 'rb') as f:
--> 336 status, response = callServer('put', serverEndpoint, service, f,
337 headers, verbose, tikaServerJar, config_path=config_path,
338 rawResponse=rawResponse, requestOptions=requestOptions)
~\anaconda3\lib\site-packages\tika\tika.py in callServer(verb, serverEndpoint, service, data, headers, verbose, tikaServerJar, httpVerbs, classpath, rawResponse, config_path, requestOptions)
529 global TikaClientOnly
530 if not TikaClientOnly:
--> 531 serverEndpoint = checkTikaServer(scheme, serverHost, port, tikaServerJar, classpath, config_path)
532
533 serviceUrl = serverEndpoint + service
~\anaconda3\lib\site-packages\tika\tika.py in checkTikaServer(scheme, serverHost, port, tikaServerJar, classpath, config_path)
590 if not alreadyRunning:
591 if not os.path.isfile(jarPath) and urlp.scheme != '':
--> 592 getRemoteJar(tikaServerJar, jarPath)
593
594 if not checkJarSig(tikaServerJar, jarPath):
~\anaconda3\lib\site-packages\tika\tika.py in getRemoteJar(urlOrPath, destPath)
806 if os.path.exists(destPath) and os.path.isfile(destPath):
807 os.remove(destPath)
--> 808 urlretrieve(urlOrPath, destPath)
809
810 return (destPath, 'remote')
~\anaconda3\lib\urllib\request.py in urlretrieve(url, filename, reporthook, data)
245 url_type, path = _splittype(url)
246
--> 247 with contextlib.closing(urlopen(url, data)) as fp:
248 headers = fp.info()
249
~\anaconda3\lib\urllib\request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
220 else:
221 opener = _opener
--> 222 return opener.open(url, data, timeout)
223
224 def install_opener(opener):
~\anaconda3\lib\urllib\request.py in open(self, fullurl, data, timeout)
523
524 sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method())
--> 525 response = self._open(req, data)
526
527 # post-process response
~\anaconda3\lib\urllib\request.py in _open(self, req, data)
545 return result
546
--> 547 return self._call_chain(self.handle_open, 'unknown',
548 'unknown_open', req)
549
~\anaconda3\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args)
500 for handler in handlers:
501 func = getattr(handler, meth_name)
--> 502 result = func(*args)
503 if result is not None:
504 return result
~\anaconda3\lib\urllib\request.py in unknown_open(self, req)
1419 def unknown_open(self, req):
1420 type = req.type
-> 1421 raise URLError('unknown url type: %s' % type)
1422
1423 def parse_keqv_list(l):
URLError: <urlopen error unknown url type: c>
I tried to unistall tika python, tika server, java, python... basically everything. And the strange thing is that suddenly I have the same issue in my second pc.
Any suggestions ? Thanks a lot.
I have created 2 Java Demo applications which connects to an already configured Azure Service Bus using the following guides:
How to use the Java Message Service (JMS) API with Service Bus and AMQP 1.0 - azure.microsoft.com/nl-nl/documentation/articles/service-bus-java-how-to-use-jms-api-amqp
Qpid JMS 0.11.1 documentation - qpid.apache.org/releases/qpid-jms-0.11.1/docs/index.html
The Sender.java app can successfully place a message in a queue on the preconfigured Azure Service Bus.
The SimpleReceiver.java app is setup to receive a message from a queue on Azure ServiceBus.
Currently the SimpleReceiver.java can successfully receive a message that was originally sent from the Sender.java app to the Service Bus. But fails to receive messasges that where sent by a .Net(C#) Sender.cs app.
How Can I implement/setup the SimpleReceiver.java to receive all messages from the Azure Service Bus Queue? (using Qpid JMS 0.11.1)
Side note: I am able to achieve this using the older library Qpid JMS 0.32. But version 0.11.1 is a necessity.
To sum up what i have so far:
[works] Sender.java -> Azure Service Bus -> SimpleReceiver.java
[works] Sender.java -> Azure Service Bus -> (.Net) Receiver.cs
[works] (.Net) Sender.cs -> Azure Service Bus -> (.Net) Receiver.cs
[fails] (.Net) Sender.cs -> Azure Service Bus -> SimpleReceiver.java
When I try to receive messages sent by .Net with the SimpleReceiver.java i get the following traces/log:
2016-11-07 09:44:18,778 [ntLoopGroup-2-1] - TRACE NettyTcpTransport - SSL Handshake has completed: [id: 0xe1a2112b, L:/10.70.1.160:57828 - R:demo-sandbox-open-bus.servicebus.windows.net/13.69.253.135:5671]
2016-11-07 09:44:18,778 [ntLoopGroup-2-1] - TRACE NettyTcpTransport - Channel has become active! Channel is [id: 0xe1a2112b, L:/10.70.1.160:57828 - R:demo-sandbox-open-bus.servicebus.windows.net/13.69.253.135:5671]
2016-11-07 09:44:18,778 [ntLoopGroup-2-1] - DEBUG SslHandler - [id: 0xe1a2112b, L:/10.70.1.160:57828 - R:demo-sandbox-open-bus.servicebus.windows.net/13.69.253.135:5671] HANDSHAKEN: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
connection :org.apache.qpid.jms.JmsConnection#c1c084f
2016-11-07 09:44:18,813 [us.windows.net]] - TRACE MetaDataSupport - Problem generating primary version details
java.lang.NullPointerException
at java.util.regex.Matcher.getTextLength(Matcher.java:1234)
at java.util.regex.Matcher.reset(Matcher.java:308)
at java.util.regex.Matcher.<init>(Matcher.java:228)
at java.util.regex.Pattern.matcher(Pattern.java:1088)
at org.apache.qpid.jms.util.MetaDataSupport.<clinit>(MetaDataSupport.java:47)
at org.apache.qpid.jms.provider.amqp.builders.AmqpConnectionBuilder.createEndpoint(AmqpConnectionBuilder.java:108)
at org.apache.qpid.jms.provider.amqp.builders.AmqpConnectionBuilder.createEndpoint(AmqpConnectionBuilder.java:41)
at org.apache.qpid.jms.provider.amqp.builders.AmqpResourceBuilder.buildResource(AmqpResourceBuilder.java:72)
at org.apache.qpid.jms.provider.amqp.builders.AmqpConnectionBuilder.buildResource(AmqpConnectionBuilder.java:94)
at org.apache.qpid.jms.provider.amqp.AmqpProvider$4$1.processConnectionInfo(AmqpProvider.java:323)
at org.apache.qpid.jms.meta.JmsConnectionInfo.visit(JmsConnectionInfo.java:373)
at org.apache.qpid.jms.provider.amqp.AmqpProvider$4.run(AmqpProvider.java:252)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
2016-11-07 09:44:18,819 [us.windows.net]] - TRACE NettyTcpTransport - Attempted write of: 8 bytes
2016-11-07 09:44:18,845 [ntLoopGroup-2-1] - TRACE NettyTcpTransport - New data read: 8 bytes incoming: UnpooledUnsafeHeapByteBuf(ridx: 0, widx: 8, cap: 37)
2016-11-07 09:44:18,846 [us.windows.net]] - TRACE AmqpProvider - New Proton Event: CONNECTION_INIT
2016-11-07 09:44:18,847 [us.windows.net]] - TRACE AmqpProvider - New Proton Event: CONNECTION_LOCAL_OPEN
2016-11-07 09:44:18,926 [ntLoopGroup-2-1] - TRACE NettyTcpTransport - New data read: 63 bytes incoming: UnpooledUnsafeHeapByteBuf(ridx: 0, widx: 63, cap: 101)
2016-11-07 09:44:18,928 [us.windows.net]] - DEBUG SaslMechanismFinder - Unknown SASL mechanism: [MSSBCBS]
2016-11-07 09:44:18,931 [us.windows.net]] - DEBUG SaslMechanismFinder - Skipping SASL-EXTERNAL mechanism because the available credentials are not sufficient
2016-11-07 09:44:18,931 [us.windows.net]] - INFO SaslMechanismFinder - Best match for SASL auth was: SASL-PLAIN
2016-11-07 09:44:18,933 [us.windows.net]] - TRACE NettyTcpTransport - Attempted write of: 125 bytes
2016-11-07 09:44:18,958 [ntLoopGroup-2-1] - TRACE NettyTcpTransport - New data read: 26 bytes incoming: UnpooledUnsafeHeapByteBuf(ridx: 0, widx: 26, cap: 53)
[395414939:0] -> Open{ containerId='ID:9669bcc7-59c0-43eb-9908-00605f8153dd:1', hostname='demo-sandbox-open-bus.servicebus.windows.net', maxFrameSize=1048576, channelMax=32767, idleTimeOut=75000, outgoingLocales=null, incomingLocales=null, offeredCapabilities=null, desiredCapabilities=[sole-connection-for-container], properties={product=QpidJMS, version=0.11.1, platform=JVM: 1.7.0_75, 24.75-b04, Oracle Corporation, OS: Windows 8.1, 6.3, amd64}}
2016-11-07 09:44:18,961 [us.windows.net]] - TRACE FRAMES - SENT: Open{ containerId='ID:9669bcc7-59c0-43eb-9908-00605f8153dd:1', hostname='demo-sandbox-open-bus.servicebus.windows.net', maxFrameSize=1048576, channelMax=32767, idleTimeOut=75000, outgoingLocales=null, incomingLocales=null, offeredCapabilities=null, desiredCapabilities=[sole-connection-for-container], properties={product=QpidJMS, version=0.11.1, platform=JVM: 1.7.0_75, 24.75-b04, Oracle Corporation, OS: Windows 8.1, 6.3, amd64}}
2016-11-07 09:44:18,961 [us.windows.net]] - TRACE NettyTcpTransport - Attempted write of: 290 bytes
2016-11-07 09:44:18,985 [ntLoopGroup-2-1] - TRACE NettyTcpTransport - New data read: 8 bytes incoming: UnpooledUnsafeHeapByteBuf(ridx: 0, widx: 8, cap: 37)
2016-11-07 09:44:19,061 [ntLoopGroup-2-1] - TRACE NettyTcpTransport - New data read: 70 bytes incoming: UnpooledUnsafeHeapByteBuf(ridx: 0, widx: 70, cap: 101)
[395414939:0] <- Open{ containerId='d3a14a268d4c45b1a5f6acabc01c1bdd_G43', hostname='null', maxFrameSize=65536, channelMax=4999, idleTimeOut=240000, outgoingLocales=null, incomingLocales=null, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,061 [us.windows.net]] - TRACE FRAMES - RECV: Open{ containerId='d3a14a268d4c45b1a5f6acabc01c1bdd_G43', hostname='null', maxFrameSize=65536, channelMax=4999, idleTimeOut=240000, outgoingLocales=null, incomingLocales=null, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,061 [us.windows.net]] - TRACE AmqpProvider - New Proton Event: CONNECTION_REMOTE_OPEN
2016-11-07 09:44:19,064 [us.windows.net]] - TRACE AmqpProvider - New Proton Event: SESSION_INIT
2016-11-07 09:44:19,064 [us.windows.net]] - TRACE AmqpProvider - New Proton Event: SESSION_LOCAL_OPEN
[395414939:0] -> Begin{remoteChannel=null, nextOutgoingId=1, incomingWindow=2047, outgoingWindow=2147483647, handleMax=65535, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,066 [us.windows.net]] - TRACE FRAMES - SENT: Begin{remoteChannel=null, nextOutgoingId=1, incomingWindow=2047, outgoingWindow=2147483647, handleMax=65535, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,066 [us.windows.net]] - TRACE NettyTcpTransport - Attempted write of: 32 bytes
2016-11-07 09:44:19,091 [ntLoopGroup-2-1] - TRACE NettyTcpTransport - New data read: 34 bytes incoming: UnpooledUnsafeHeapByteBuf(ridx: 0, widx: 34, cap: 69)
[395414939:0] <- Begin{remoteChannel=0, nextOutgoingId=1, incomingWindow=5000, outgoingWindow=2047, handleMax=255, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,091 [us.windows.net]] - TRACE FRAMES - RECV: Begin{remoteChannel=0, nextOutgoingId=1, incomingWindow=5000, outgoingWindow=2047, handleMax=255, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,091 [us.windows.net]] - TRACE AmqpProvider - New Proton Event: SESSION_REMOTE_OPEN
2016-11-07 09:44:19,091 [us.windows.net]] - DEBUG AmqpConnectionBuilder - AmqpConnection { ID:13845de8-37ce-42de-8d5d-2e4d9de7352f:1 } is now open:
2016-11-07 09:44:19,091 [us.windows.net]] - TRACE AmqpProvider - IdleTimeoutCheck being initiated, initial delay: 120000
2016-11-07 09:44:19,092 [us.windows.net]] - INFO JmsConnection - Connection ID:13845de8-37ce-42de-8d5d-2e4d9de7352f:1 connected to remote Broker: amqps://demo-sandbox-open-bus.servicebus.windows.net
[395414939:1] -> Begin{remoteChannel=null, nextOutgoingId=1, incomingWindow=2047, outgoingWindow=2147483647, handleMax=65535, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,102 [us.windows.net]] - TRACE FRAMES - SENT: Begin{remoteChannel=null, nextOutgoingId=1, incomingWindow=2047, outgoingWindow=2147483647, handleMax=65535, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,102 [us.windows.net]] - TRACE NettyTcpTransport - Attempted write of: 32 bytes
2016-11-07 09:44:19,126 [ntLoopGroup-2-1] - TRACE NettyTcpTransport - New data read: 34 bytes incoming: UnpooledUnsafeHeapByteBuf(ridx: 0, widx: 34, cap: 69)
[395414939:1] <- Begin{remoteChannel=1, nextOutgoingId=1, incomingWindow=5000, outgoingWindow=2047, handleMax=255, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,126 [us.windows.net]] - TRACE FRAMES - RECV: Begin{remoteChannel=1, nextOutgoingId=1, incomingWindow=5000, outgoingWindow=2047, handleMax=255, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,126 [us.windows.net]] - TRACE AmqpProvider - New Proton Event: SESSION_INIT
2016-11-07 09:44:19,126 [us.windows.net]] - TRACE AmqpProvider - New Proton Event: SESSION_LOCAL_OPEN
2016-11-07 09:44:19,126 [us.windows.net]] - TRACE AmqpProvider - New Proton Event: SESSION_REMOTE_OPEN
[395414939:1] -> Attach{name='qpid-jms:receiver:ID:13845de8-37ce-42de-8d5d-2e4d9de7352f:1:1:1:a_receiver/verwerker/klant', handle=0, role=RECEIVER, sndSettleMode=UNSETTLED, rcvSettleMode=FIRST, source=Source{address='a_receiver/verwerker/klant', durable=NONE, expiryPolicy=LINK_DETACH, timeout=0, dynamic=false, dynamicNodeProperties=null, distributionMode=null, filter=null, defaultOutcome=Modified{deliveryFailed=true, undeliverableHere=null, messageAnnotations=null}, outcomes=[amqp:accepted:list, amqp:rejected:list, amqp:released:list, amqp:modified:list], capabilities=[queue]}, target=Target{address='null', durable=NONE, expiryPolicy=SESSION_END, timeout=0, dynamic=false, dynamicNodeProperties=null, capabilities=null}, unsettled=null, incompleteUnsettled=false, initialDeliveryCount=null, maxMessageSize=null, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,138 [us.windows.net]] - TRACE FRAMES - SENT: Attach{name='qpid-jms:receiver:ID:13845de8-37ce-42de-8d5d-2e4d9de7352f:1:1:1:a_receiver/verwerker/klant', handle=0, role=RECEIVER, sndSettleMode=UNSETTLED, rcvSettleMode=FIRST, source=Source{address='a_receiver/verwerker/klant', durable=NONE, expiryPolicy=LINK_DETACH, timeout=0, dynamic=false, dynamicNodeProperties=null, distributionMode=null, filter=null, defaultOutcome=Modified{deliveryFailed=true, undeliverableHere=null, messageAnnotations=null}, outcomes=[amqp:accepted:list, amqp:rejected:list, amqp:released:list, amqp:modified:list], capabilities=[queue]}, target=Target{address='null', durable=NONE, expiryPolicy=SESSION_END, timeout=0, dynamic=false, dynamicNodeProperties=null, capabilities=null}, unsettled=null, incompleteUnsettled=false, initialDeliveryCount=null, maxMessageSize=null, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,138 [us.windows.net]] - TRACE NettyTcpTransport - Attempted write of: 276 bytes
2016-11-07 09:44:19,164 [ntLoopGroup-2-1] - TRACE NettyTcpTransport - New data read: 310 bytes incoming: UnpooledUnsafeHeapByteBuf(ridx: 0, widx: 310, cap: 341)
[395414939:1] <- Attach{name='qpid-jms:receiver:ID:13845de8-37ce-42de-8d5d-2e4d9de7352f:1:1:1:a_receiver/verwerker/klant', handle=0, role=SENDER, sndSettleMode=MIXED, rcvSettleMode=SECOND, source=Source{address='a_receiver/verwerker/klant', durable=NONE, expiryPolicy=LINK_DETACH, timeout=0, dynamic=false, dynamicNodeProperties=null, distributionMode=null, filter=null, defaultOutcome=Modified{deliveryFailed=true, undeliverableHere=null, messageAnnotations=null}, outcomes=[amqp:accepted:list, amqp:rejected:list, amqp:released:list, amqp:modified:list], capabilities=[queue]}, target=Target{address='null', durable=NONE, expiryPolicy=SESSION_END, timeout=0, dynamic=false, dynamicNodeProperties=null, capabilities=null}, unsettled=null, incompleteUnsettled=false, initialDeliveryCount=0, maxMessageSize=266240, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,164 [us.windows.net]] - TRACE FRAMES - RECV: Attach{name='qpid-jms:receiver:ID:13845de8-37ce-42de-8d5d-2e4d9de7352f:1:1:1:a_receiver/verwerker/klant', handle=0, role=SENDER, sndSettleMode=MIXED, rcvSettleMode=SECOND, source=Source{address='a_receiver/verwerker/klant', durable=NONE, expiryPolicy=LINK_DETACH, timeout=0, dynamic=false, dynamicNodeProperties=null, distributionMode=null, filter=null, defaultOutcome=Modified{deliveryFailed=true, undeliverableHere=null, messageAnnotations=null}, outcomes=[amqp:accepted:list, amqp:rejected:list, amqp:released:list, amqp:modified:list], capabilities=[queue]}, target=Target{address='null', durable=NONE, expiryPolicy=SESSION_END, timeout=0, dynamic=false, dynamicNodeProperties=null, capabilities=null}, unsettled=null, incompleteUnsettled=false, initialDeliveryCount=0, maxMessageSize=266240, offeredCapabilities=null, desiredCapabilities=null, properties=null}
2016-11-07 09:44:19,165 [us.windows.net]] - TRACE AmqpProvider - New Proton Event: LINK_INIT
2016-11-07 09:44:19,165 [us.windows.net]] - TRACE AmqpProvider - New Proton Event: LINK_LOCAL_OPEN
2016-11-07 09:44:19,165 [us.windows.net]] - TRACE AmqpProvider - New Proton Event: LINK_REMOTE_OPEN
2016-11-07 09:44:19,166 [us.windows.net]] - TRACE AmqpConsumer - Consumer ID:13845de8-37ce-42de-8d5d-2e4d9de7352f:1:1:1 granting additional credit: 1000
receiver.getMessageSelector(): is null
[395414939:1] -> Flow{nextIncomingId=1, incomingWindow=2047, nextOutgoingId=1, outgoingWindow=2147483647, handle=0, deliveryCount=0, linkCredit=1000, available=null, drain=false, echo=false, properties=null}
2016-11-07 09:44:19,167 [us.windows.net]] - TRACE FRAMES - SENT: Flow{nextIncomingId=1, incomingWindow=2047, nextOutgoingId=1, outgoingWindow=2147483647, handle=0, deliveryCount=0, linkCredit=1000, available=null, drain=false, echo=false, properties=null}
2016-11-07 09:44:19,167 [us.windows.net]] - TRACE NettyTcpTransport - Attempted write of: 35 bytes
Type 'exit' + [enter] to quit.
2016-11-07 09:44:19,194 [ntLoopGroup-2-1] - TRACE NettyTcpTransport - New data read: 548 bytes incoming: UnpooledUnsafeHeapByteBuf(ridx: 0, widx: 548, cap: 581)
[395414939:1] <- Transfer{handle=0, deliveryId=0, deliveryTag=~\x00\x5c#\xa0j\xd6A\x92N\x82\x91\x1a\x09\xd3\x12, messageFormat=0, settled=null, more=false, rcvSettleMode=null, state=null, resume=false, aborted=false, batchable=true} (506) "\x00Sp\xc0\x0a\x05##p\x0er\xbb\x00#C\x00Sr\xc1\x5c\x06\xa3\x13x-opt-enqueued-time\x83\x00\x00\x01X=\xf5\x108\xa3\x15x-opt-sequence-number\x81\x00\x00\x00\x00\x00\x00\x01\xca\xa3\x12x-opt-locked-until\x83\x00\x00\x01X=\xf6\x96\xcf\x00Ss\xc0=\x0d\xa1\x1dtestsender2016-11-07T09:43:38#####\xa3\x10application/json######\x00St\xc1\xb5\x0e\xa1\x0bMessageType\xa1\x0fDocumentMessage\xa1\x0cSourceSystem\xa1\x0asis_sender\xa1\x0dEnterpriseKey\xa1\x18sis_sender-klant-bericht\xa1\x08TenantId\xa1\x05klant\xa1\x09EventType\xa1\x07bericht\xa1\x10EventTypeVersion\xa1\x031.0\xa1\x0dOperationType\xa1\x06Create\x00Su\xa0\x89#\x06string\x083http://schemas.microsoft.com/2003/10/Serialization/\x99J{"id": 1,"name": "A .net door","price": 12.50,"tags": ["home", "C# .Net"]}"
2016-11-07 09:44:19,201 [us.windows.net]] - TRACE FRAMES - RECV: Transfer{handle=0, deliveryId=0, deliveryTag=~\x00\x5c#\xa0j\xd6A\x92N\x82\x91\x1a\x09\xd3\x12, messageFormat=0, settled=null, more=false, rcvSettleMode=null, state=null, resume=false, aborted=false, batchable=true}
2016-11-07 09:44:19,203 [us.windows.net]] - TRACE AmqpProvider - New Proton Event: DELIVERY
2016-11-07 09:44:19,203 [us.windows.net]] - TRACE AmqpConsumer - AmqpConsumer { ID:13845de8-37ce-42de-8d5d-2e4d9de7352f:1:1:1 } has incoming Message(s).
2016-11-07 09:44:19,210 [us.windows.net]] - DEBUG AmqpConsumer - Dispatching received message: JmsInboundMessageDispatch {sequence = 1, messageId = testsender2016-11-07T09:43:38, consumerId = ID:13845de8-37ce-42de-8d5d-2e4d9de7352f:1:1:1}
2016-11-07 09:44:19,211 [1:1] dispatcher] - TRACE JmsMessageConsumer - checking envelope with 0 redeliveries
2016-11-07 09:44:19,212 [us.windows.net]] - DEBUG AmqpConsumer - Delivered Ack of message: JmsInboundMessageDispatch {sequence = 1, messageId = testsender2016-11-07T09:43:38, consumerId = ID:13845de8-37ce-42de-8d5d-2e4d9de7352f:1:1:1}
I also have a comparison of a message sent by Java vs one sent by .net(C#) (messages exported from Service Bus Explorer). I have a feeling it has something to do with the contentType/ type of message sent.
Below are traces/logs of a successfull message sent by Java and a Unsucceful message sent by .Net:
[2138532527:1] <- Transfer{handle=0, deliveryId=0, deliveryTag=Z\x80\x91\x15\xa3v{D\x96`\x04\x1ad\xb8;V, messageFormat=0, settled=null, more=false, rcvSettleMode=null, state=null, resume=false, aborted=false, batchable=true} (529) "\x00Sp\xc0\x0a\x05B#p\x0er\xbb\x00#C\x00Sr\xc1\x84\x0a\xa3\x12x-opt-jms-msg-typeQ\x05\xa3\x0ex-opt-jms-destQ\x00\xa3\x13x-opt-enqueued-time\x83\x00\x00\x01X*i\x17!\xa3\x15x-opt-sequence-number\x81\x00\x00\x00\x00\x00\x00\x01\xa9\xa3\x12x-opt-locked-until\x83\x00\x00\x01X*j\x01\x91\x00Ss\xc0t\x0d\xa1/ID:e076122e-f27d-4cdd-9b13-33e75716d70a:1:1:1-1#\xa1\x1csis_receiver/verwerker/klant\xa1\x10application/json#####\x83\x00\x00\x01X*i\x12h###\x00St\xc1\xb5\x0e\xa1\x08TenantId\xa1\x05klant\xa1\x0dEnterpriseKey\xa1\x18sis_sender-klant-bericht\xa1\x09EventType\xa1\x07bericht\xa1\x10EventTypeVersion\xa1\x031.0\xa1\x0bMessageType\xa1\x0fDocumentMessage\xa1\x0dOperationType\xa1\x06Create\xa1\x0cSourceSystem\xa1\x0asis_sender\x00Sw\xa1A{"logged":false,"userID":"0","bericht Marvin Java":"test body2"} "
Received message with JMSMessageID = ID:e076122e-f27d-4cdd-9b13-33e75716d70a:1:1:1-1
[2138532527:1] -> Disposition{role=RECEIVER, first=0, last=0, settled=true, state=Accepted{}, batchable=false}
[2138532527:1] <- Transfer{handle=0, deliveryId=1, deliveryTag=\xd7\xbb\x1b\xcb>\x91\x14O\xa2\x83q\x9e\xc9|N\x09, messageFormat=0, settled=null, more=false, rcvSettleMode=null, state=null, resume=false, aborted=false, batchable=true} (504) "\x00Sp\xc0\x0a\x05##p\x0er\xbb\x00#C\x00Sr\xc1\x5c\x06\xa3\x13x-opt-enqueued-time\x83\x00\x00\x01X*i\x5c\x10\xa3\x15x-opt-sequence-number\x81\x00\x00\x00\x00\x00\x00\x01\xaa\xa3\x12x-opt-locked-until\x83\x00\x00\x01X*jFp\x00Ss\xc0=\x0d\xa1\x1dtestsender2016-11-03T14:38:15#####\xa3\x10application/json######\x00St\xc1\xb5\x0e\xa1\x0bMessageType\xa1\x0fDocumentMessage\xa1\x0cSourceSystem\xa1\x0asis_sender\xa1\x0dEnterpriseKey\xa1\x18sis_sender-klant-bericht\xa1\x08TenantId\xa1\x05klant\xa1\x09EventType\xa1\x07bericht\xa1\x10EventTypeVersion\xa1\x031.0\xa1\x0dOperationType\xa1\x06Create\x00Su\xa0\x87#\x06string\x083http://schemas.microsoft.com/2003/10/Serialization/\x99H{"id": 1,"name": "A .net door","price": 12.50,"tags": ["home", "green"]}"
I have the follwing properties file servicebus.properties:
# Set the InitialContextFactory class to use
java.naming.factory.initial = org.apache.qpid.jms.jndi.JmsInitialContextFactory
# Define the required ConnectionFactory instances
# connectionfactory.<JNDI-lookup-name> = <URI>
connectionfactory.myFactoryLookup = amqps://demo-sandbox-open-bus.servicebus.windows.net?amqp.idleTimeout=150000&amqp.traceFrames=true&jms.username=somePolicy&jms.password=aM1k3PaXY5jdIkmGKm7G%2FcH%2BUFQaFAgHIYc3dSsuiLI%3D
# Register some queues in JNDI using the form
# queue.[jndi_name] = [physical_name]
# topic.[jndi_name] = [physical_name]
queue.myQueueLookup = queue1
I have the following class SimpleReceiver.java:
package com.demo.AzureTest;
import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Hashtable;
import java.util.Random;
public class SimpleReceiver implements MessageListener {
private Connection connection;
private Session receiveSession;
private MessageConsumer receiver;
private static Random randomGenerator = new Random();
public SimpleReceiver() throws Exception {
Context context = new InitialContext();
ConnectionFactory cf = (ConnectionFactory) context.lookup("myFactoryLookup");
Destination queue = (Destination) context.lookup("myQueueLookup");
// Create Connection
connection = cf.createConnection();
System.out.println("connection :"+connection);
// Create receiver-side Session, MessageConsumer,and MessageListener
receiveSession = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
receiver = receiveSession.createConsumer(queue);
if (receiver.getMessageSelector() != null){
System.out.println("receiver.getMessageSelector(): " + receiver.getMessageSelector());
}
else {
System.out.println("receiver.getMessageSelector(): is null" );
}
receiver.setMessageListener(this);
connection.start();
}
public static void main(String[] args) {
try {
SimpleReceiver simpleSenderReceiver = new SimpleReceiver();
System.out.println("Type 'exit' + [enter] to quit.");
BufferedReader commandLine = new java.io.BufferedReader(new InputStreamReader(System.in));
while (true) {
String s = commandLine.readLine();
if (s.equalsIgnoreCase("exit")) {
simpleSenderReceiver.close();
System.exit(0);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void close() throws JMSException {
connection.close();
}
public void onMessage(Message message) {
try {
System.out.println("Received message with JMSMessageID = " + message.getJMSMessageID());
TextMessage txtmessage = (TextMessage) message;
System.out.println("Received message with Text = " + txtmessage.getText());
message.acknowledge();
} catch (Exception e) {
e.printStackTrace();
}
}
}
I have the following class Sender.java:
package com.demo.QpidTest;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.DeliveryMode;
import javax.jms.Destination;
import javax.jms.ExceptionListener;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
public class Sender {
private static final int DEFAULT_COUNT = 1;
private static final int DELIVERY_MODE = DeliveryMode.NON_PERSISTENT;
private static Random randomGenerator = new Random();
public static void main(String[] args) throws Exception {
int count = DEFAULT_COUNT;
if (args.length == 0) {
System.out.println("Sending up to " + count + " messages.");
} else {
count = Integer.parseInt(args[0]);
System.out.println("Sending up to " + count + " messages.");
}
try {
// The configuration for the Qpid InitialContextFactory has been supplied in
// a jndi.properties file in the classpath, which results in it being picked
// up automatically by the InitialContext constructor.
Context context = new InitialContext();
ConnectionFactory factory = (ConnectionFactory) context.lookup("myFactoryLookup");
Destination queue = (Destination) context.lookup("myQueueLookup");
Connection connection = factory.createConnection();
connection.setExceptionListener(new MyExceptionListener());
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer messageProducer = session.createProducer(queue);
long start = System.currentTimeMillis();
for (int i = 1; i <= count; i++) {
// TextMessage message = session.createTextMessage("Text!");
TextMessage message = session.createTextMessage("{\"id\": 1,\"name\": \"A .net door\",\"price\": 12.50,\"tags\": [\"home\", \"green\"]}");
long randomMessageID = randomGenerator.nextLong() >>>1;
message.setStringProperty("TenantId", "klant");
message.setStringProperty("EventType", "bericht");
message.setStringProperty("EventTypeVersion", "1.0");
message.setStringProperty("MessageType", "DocumentMessage");
message.setStringProperty("OperationType", "Create");
message.setStringProperty("SourceSystem", "sis_sender");
message.setStringProperty("EnterpriseKey", "sender-lant-bericht");
message.setJMSMessageID("ID:" + randomMessageID);
messageProducer.send(message, DELIVERY_MODE, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
if (i % 100 == 0) {
System.out.println("Sent message " + i);
}
}
long finish = System.currentTimeMillis();
long taken = finish - start;
System.out.println("Sent " + count + " messages in " + taken + "ms");
connection.close();
} catch (Exception exp) {
System.out.println("Caught exception, exiting.");
exp.printStackTrace(System.out);
System.exit(1);
}
}
private static class MyExceptionListener implements ExceptionListener {
#Override
public void onException(JMSException exception) {
System.out.println("Connection ExceptionListener fired, exiting.");
exception.printStackTrace(System.out);
System.exit(1);
}
}
}
Using QPID Java Client i can only get messages delivered through the exchange to the bound queue using the following expanded syntax of AMQAnyDestination
Destination queue = new AMQAnyDestination( new AMQShortString("onms2"),
new AMQShortString("direct"),
new AMQShortString("Simon"),
true,
true,
new AMQShortString(""),
false,
bindvars);
If i attempt to use the different form which just specifies the address as follows it doesnt work:-
Destination queue = new AMQAnyDestination("onms2/Simon");
The message hits RabbitMQ ok but is not delivered.
Qpid 0.32 Client
Rabbit MQ 3.5.7
Exchange onms
Routing Key Simon
I have been using the qpid examples and modifying the ListSender example as below
package org.apache.qpid.example;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.Message;
import javax.jms.MessageProducer;
import javax.jms.Session;
import org.apache.qpid.client.AMQAnyDestination;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.jms.ListMessage;
public class ListSender {
public static void main(String[] args) throws Exception
{
Connection connection =
new AMQConnection("amqp://simon:simon#localhost/test?brokerlist='tcp://localhost:5672'");
AMQShortString a1 = new AMQShortString("");
AMQShortString a2 = new AMQShortString("");
AMQShortString[] bindvars = new AMQShortString[]{a1,a2};
boolean is_durable = true;
/*
Destination queue = new AMQAnyDestination( new AMQShortString("onms2"),
new AMQShortString("direct"),
new AMQShortString("Simon"),
true,
true,
new AMQShortString(""),
false,
bindvars);
*/
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination queue = new AMQAnyDestination("onms2/Simon");
//Destination queue = new AMQAnyDestination("amqp:OpenNMSExchange/Taylor; {create: always}");
//Destination queue = new AMQAnyDestination("OpenNMSExchange; {create: always}");
MessageProducer producer = session.createProducer(queue);
ListMessage m = ((org.apache.qpid.jms.Session)session).createListMessage();
m.setIntProperty("Id", 987654321);
m.setStringProperty("name", "WidgetSimon");
m.setDoubleProperty("price", 0.99);
List<String> colors = new ArrayList<String>();
colors.add("red");
colors.add("green");
colors.add("white");
m.add(colors);
Map<String,Double> dimensions = new HashMap<String,Double>();
dimensions.put("length",10.2);
dimensions.put("width",5.1);
dimensions.put("depth",2.0);
m.add(dimensions);
List<List<Integer>> parts = new ArrayList<List<Integer>>();
parts.add(Arrays.asList(new Integer[] {1,2,5}));
parts.add(Arrays.asList(new Integer[] {8,2,5}));
m.add(parts);
Map<String,Object> specs = new HashMap<String,Object>();
specs.put("colours", colors);
specs.put("dimensions", dimensions);
specs.put("parts", parts);
m.add(specs);
producer.send((Message)m);
System.out.println("Sent: " + m);
connection.close();
}
}
When it works using the expanded format of AMQAnyDestination the debug logs looks like this:-
163 [main] INFO org.apache.qpid.client.AMQConnection - Connection 1 now connected from /127.0.0.1:43298 to localhost/127.0.0.1:5672
163 [main] DEBUG org.apache.qpid.client.AMQConnection - Are we connected:true
163 [main] DEBUG org.apache.qpid.client.AMQConnection - Connected with ProtocolHandler Version:0-91
166 [main] DEBUG org.apache.qpid.client.AMQDestination - Based on direct://onms2/Simon/?routingkey='Simon'&exclusive='true'&autodelete='true' the selected destination syntax is BURL
169 [main] DEBUG org.apache.qpid.client.AMQConnectionDelegate_8_0 - Write channel open frame for channel id 1
184 [main] DEBUG org.apache.qpid.client.AMQSession - Created session:org.apache.qpid.client.AMQSession_0_8#1d251891
186 [IoReceiver - localhost/127.0.0.1:5672] DEBUG org.apache.qpid.client.protocol.AMQProtocolHandler - (1028176102)Method frame received: [ChannelOpenOkBody]
189 [IoReceiver - localhost/127.0.0.1:5672] DEBUG org.apache.qpid.client.protocol.AMQProtocolHandler - (1028176102)Method frame received: [BasicQosOkBodyImpl: ]
195 [main] DEBUG org.apache.qpid.client.BasicMessageProducer_0_8 - MessageProducer org.apache.qpid.client.BasicMessageProducer_0_8#668bc3d5 using publish mode : ASYNC_PUBLISH_ALL
206 [main] DEBUG org.apache.qpid.client.BasicMessageProducer_0_8 - Sending content body frames to direct://onms2/Simon/?routingkey='Simon'&exclusive='true'&autodelete='true'
206 [main] DEBUG org.apache.qpid.client.BasicMessageProducer_0_8 - Sending content header frame to direct://onms2/Simon/?routingkey='Simon'&exclusive='true'&autodelete='true'
207 [main] DEBUG org.apache.qpid.framing.FieldTable - FieldTable::writeToBuffer: Writing encoded length of 67...
When it fails using the shorter syntax the debug log looks like this:-
149 [main] INFO org.apache.qpid.client.AMQConnection - Connection 1 now connected from /127.0.0.1:36940 to localhost/127.0.0.1:5672
149 [main] DEBUG org.apache.qpid.client.AMQConnection - Are we connected:true
149 [main] DEBUG org.apache.qpid.client.AMQConnection - Connected with ProtocolHandler Version:0-91
153 [main] DEBUG org.apache.qpid.client.AMQConnectionDelegate_8_0 - Write channel open frame for channel id 1
169 [main] DEBUG org.apache.qpid.client.AMQSession - Created session:org.apache.qpid.client.AMQSession_0_8#6bdf28bb
170 [IoReceiver - localhost/127.0.0.1:5672] DEBUG org.apache.qpid.client.protocol.AMQProtocolHandler - (472294496)Method frame received: [ChannelOpenOkBody]
171 [IoReceiver - localhost/127.0.0.1:5672] DEBUG org.apache.qpid.client.protocol.AMQProtocolHandler - (472294496)Method frame received: [BasicQosOkBodyImpl: ]
179 [main] DEBUG org.apache.qpid.client.AMQDestination - Based on onms2/Simon the selected destination syntax is ADDR
182 [main] DEBUG org.apache.qpid.client.AMQConnectionDelegate_8_0 - supportsIsBound: false
182 [main] DEBUG org.apache.qpid.client.AMQConnectionDelegate_8_0 - supportsIsBound: false
182 [main] DEBUG org.apache.qpid.client.AMQConnectionDelegate_8_0 - supportsIsBound: false
184 [IoReceiver - localhost/127.0.0.1:5672] DEBUG org.apache.qpid.client.protocol.AMQProtocolHandler - (472294496)Method frame received: [ExchangeDeclareOkBodyImpl: ]
184 [main] DEBUG org.apache.qpid.client.BasicMessageProducer_0_8 - MessageProducer org.apache.qpid.client.BasicMessageProducer_0_8#15975490 using publish mode : ASYNC_PUBLISH_ALL
195 [main] DEBUG org.apache.qpid.client.BasicMessageProducer_0_8 - Sending content body frames to 'onms2'/'Simon'; None
195 [main] DEBUG org.apache.qpid.client.BasicMessageProducer_0_8 - Sending content header frame to 'onms2'/'Simon'; None
196 [main] DEBUG org.apache.qpid.framing.FieldTable - FieldTable::writeToBuffer: Writing encoded length of 90...
196 [main] DEBUG org.apache.qpid.framing.FieldTable - {Id=[INT: 987654321], name=[LONG_STRING: WidgetSimon], price=[DOUBLE: 0.99], qpid.subject=[LONG_STRING: Simon], JMS_QPID_DESTTYPE=[INT: 2]}
198 [main] DEBUG org.apache.qpid.client.AMQSession - Closing session: org.apache.qpid.client.AMQSession_0_8#6bdf28bb
198 [main] DEBUG org.apache.qpid.client.protocol.AMQProtocolSession - closeSession called on protocol session for session 1
Ideally i need the shorter syntax to work as this is what is used by another application I am using which is posting messages using AMQP.
I suspect there is something incorrect with the syntax i am using to define the address but i cant see what it is.
I have tried:-
amqp:onms2/Simon
ADDR:onms2/Simon
I have confirmed the rabbit config is correct by testing using both a standalone java client using qpid and also using both perl (using net_amqp) and python (using pika). So i dont think its that.
Any gudiance appreciated.
EDIT:-
Found some extra configuration parameters on the QPID website i had missed
When i configure the address as follows it works!
onms3/Simon; {'create':'always','node':{'type':'topic'} }
Detail
<name> [ / <subject> ] ; {
create: always | sender | receiver | never,
delete: always | sender | receiver | never,
assert: always | sender | receiver | never,
mode: browse | consume,
node: {
type: queue | topic,
durable: True | False,
x-declare: { ... <declare-overrides> ... },
x-bindings: [<binding_1>, ... <binding_n>]
},
link: {
name: <link-name>,
durable: True | False,
reliability: unreliable | at-most-once | at-least-once | exactly-once,
x-declare: { ... <declare-overrides> ... },
x-bindings: [<binding_1>, ... <binding_n>],
x-subscribe: { ... <subscribe-overrides> ... }
}
}
Simon
EDIT:-
Found some extra configuration parameters on the QPID website i had missed
When i configure the address as follows it works!
onms3/Simon; {'create':'always','node':{'type':'topic'} }
Detail
<name> [ / <subject> ] ; {
create: always | sender | receiver | never,
delete: always | sender | receiver | never,
assert: always | sender | receiver | never,
mode: browse | consume,
node: {
type: queue | topic,
durable: True | False,
x-declare: { ... <declare-overrides> ... },
x-bindings: [<binding_1>, ... <binding_n>]
},
link: {
name: <link-name>,
durable: True | False,
reliability: unreliable | at-most-once | at-least-once | exactly-once,
x-declare: { ... <declare-overrides> ... },
x-bindings: [<binding_1>, ... <binding_n>],
x-subscribe: { ... <subscribe-overrides> ... }
}
}