using Oracle Advanced Queue through JMS: NPE thrown at AQjmsProducer.jdbcEnqueue - java

I'd like to use Oracle Advanced queue via JMS.
I've create queue table and queue via plsql like this:
BEGIN
DBMS_AQADM.CREATE_QUEUE_TABLE(
queue_table => 'QT3',
queue_payload_type => 'RAW');
END;
/
BEGIN
DBMS_AQADM.CREATE_QUEUE(
queue_name => 'Q3',
queue_table => 'QT3');
END;
/
Then I try to send a message like this:
System.setProperty("oracle.jms.traceLevel", "6");
ConnectionFactory connectionFactory = AQjmsFactory.getConnectionFactory("x.x.x.x", "xxx", 1521, "thin");
Connection connection = connectionFactory.createConnection("xxx", "xxx");
connection.start();
Session session = connection.createSession(true, 0);
Queue queue = session.createQueue("Q3");
MessageProducer producer = session.createProducer(queue);
TextMessage message = session.createTextMessage("valami");
message.setJMSType("text");
producer.send(message);
session.commit();
The above code finds the queue (If I replace Q3 to something else then it says queue not found, so I guess that basic connection setup is OK), but I got NPE exception at producer.send. I set aqapi trace and I got this output:
main [Fri Jun 20 14:22:51 CEST 2014] AQjmsProducer.send-1: entry
main [Fri Jun 20 14:22:51 CEST 2014] AQjmsProducer.send-main: entry
main [Fri Jun 20 14:22:51 CEST 2014] AQjmsProducer.send: queue: RISKOPALL.Q3
main [Fri Jun 20 14:22:51 CEST 2014] AQjmsProducer.send: dest_queue: RISKOPALL.Q3
main [Fri Jun 20 14:22:51 CEST 2014] AQjmsProducer.jdbcEnqueue: entry
main [Fri Jun 20 14:22:51 CEST 2014] AQjmsProducer.checkMessageType: adt type: null
main [Fri Jun 20 14:22:51 CEST 2014] AQjmsProducer.checkMessageType: message_class: oracle.jms.AQjmsTextMessage
main [Fri Jun 20 14:22:51 CEST 2014] AQjmsProducer.jdbcEnqueue: exit
Exception in thread "main" java.lang.NullPointerException
at oracle.jms.AQjmsProducer.checkMessageType(AQjmsProducer.java:2362)
at oracle.jms.AQjmsProducer.jdbcEnqueue(AQjmsProducer.java:823)
at oracle.jms.AQjmsProducer.send(AQjmsProducer.java:747)
at oracle.jms.AQjmsProducer.send(AQjmsProducer.java:517)
at aqjms.AqJmsTest.main(AqJmsTest.java:55)
I decompiled aqapi.jar and found that the NPE is thrown because "adtType" parameter is null at AQjmsProducer.checkMessageType.
What is this ADT type and How shall I set it correctly?
Thank you very much!

Setting the payload type of the queue solved the problem:
BEGIN
DBMS_AQADM.CREATE_QUEUE_TABLE(
queue_table => 'QT3',
queue_payload_type => 'SYS.AQ$_JMS_TEXT_MESSAGE',
compatible => '8.1.0');
END;
/

Related

Spring Crontab pattern: every weekday at specific times

Here is the documentation for the Spring Crontab syntax.
I want to run a task every weekday at 14:40, 14:45, 14:50, 14:55, and 15:00, but I can't figure out how to express this with a Crontab pattern. The closest I've come up with so far is:
0 40/5 14 * * MON-FRI
But this doesn't run at 15:00.
Is this possible to express with a Crontab pattern at all?
You need to split it into two expressions :
0 40-55/5 14 * * MON-FRI
0 0 15 * * MON-FRI
If you only want to have one expression and you are okay with the last trigger time in a day run one minute before, you can use :
0 40-55/5,59 14 * * MON-FRI
Spring internally use CronSequenceGenerator to generate the next trigger time for a cron expression. You can use it to verify a cron expression.
For example , to verify the next several trigger times of 0 40-55/5,59 14 * * MON-FRI:
CronSequenceGenerator generator = new CronSequenceGenerator("0 40-55/5,59 14 * * MON-FRI");
Date d = Date.from(LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant());
for (int i = 0; i < 10; i++) {
d = generator.next(d);
System.out.println(d);
}
which will print out :
Tue Jun 02 14:40:00 HKT 2020
Tue Jun 02 14:45:00 HKT 2020
Tue Jun 02 14:50:00 HKT 2020
Tue Jun 02 14:55:00 HKT 2020
Tue Jun 02 14:59:00 HKT 2020
Wed Jun 03 14:40:00 HKT 2020
Wed Jun 03 14:45:00 HKT 2020
Wed Jun 03 14:50:00 HKT 2020
Wed Jun 03 14:55:00 HKT 2020
Wed Jun 03 14:59:00 HKT 2020

Smack FileTransferManager.addFileTransferListener is never called

I 'm developing a standalone Java test application using smack 4.3.4. I use In-Band for file transfers:
FileTransferManager fileTransferManager = FileTransferManager.getInstanceFor(connection);
FileTransferNegotiator.IBB_ONLY = true;
OutgoingFileTransfer fileTransfer = null;
try {
fileTransfer = fileTransferManager.createOutgoingFileTransfer(JidCreate.entityFullFrom(buddyJID + "/Spark"));
} catch (XmppStringprepException ex) {
LOG.log(Level.SEVERE, null, ex);
}
if (fileTransfer != null) {
OutgoingFileTransfer.setResponseTimeout(500);
...
try {
fileTransfer.sendFile(file, "sending attachment...");
} catch (SmackException ex) {
LOG.log(Level.SEVERE, null, ex);
}
...
I monitor the file transfer and it is sent correctly.
INFO: Initializing connection to server localhost port 5222 [Wed Apr 29 15:36:25 CEST 2020]
INFO: Connected: true [Wed Apr 29 15:36:45 CEST 2020]
INFO: user001 authenticated? true [Wed Apr 29 15:36:46 CEST 2020]
...
INFO: Sending attachment 'test.txt' to user user002#localhost [Wed Apr 29 15:36:55 CEST 2020]
INFO: status is:Initial [Wed Apr 29 15:36:55 CEST 2020]
INFO: status is:Initial [Wed Apr 29 15:36:55 CEST 2020]
INFO: File transfer status: Negotiating Transfer, progress: 0.0 [Wed Apr 29 15:36:55 CEST 2020]
INFO: test.txt has been successfully transferred. [Wed Apr 29 15:36:56 CEST 2020]
INFO: The file transfer is done. [Wed Apr 29 15:36:56 CEST 2020]
INFO: Attachment test.txt sent from user001#localhost to user002#localhost [Wed Apr 29 15:36:56 CEST 2020]
When my user(s) connect and login to Openfire, even before the start sending attachments, I add a listener to listen to file transfers:
final FileTransferManager manager = FileTransferManager.getInstanceFor(connection);
// FileTransferNegotiator.setServiceEnabled(connection, true);
manager.addFileTransferListener((FileTransferRequest request) -> {
// Check to see if the request should be accepted
if (request.getFileName() != null) {
try {
// Accept it
IncomingFileTransfer transfer = request.accept();
// monitorFileTransfer(transfer, "");
try (InputStream fileReceived = transfer.receiveFile();
BufferedInputStream bis = new BufferedInputStream(fileReceived)) {
...
} else {
try {
// Reject it
request.reject();
LOG.warning("File rejected " + request.getFileName());
} catch (SmackException.NotConnectedException | InterruptedException ex) {
LOG.log(Level.SEVERE, null, ex);
}
}
However, the listener is never called. Do I need to add the listener at a specific moment? Is there something else I 've been missing? The results is that the file transfers are being sent to Openfire and are never consumed.
Last stanzas:
<iq xmlns="jabber:client" to="user001#localhost/aktuu2n806" from="localhost" id="679-1085" type="get">
<query xmlns="jabber:iq:version"/>
</iq>
<iq xmlns="jabber:client" to="localhost" id="679-1085" type="error">
<error xmlns="jabber:client" type="modify">
<not-acceptable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
</error>
</iq>
My code is based on the documentation example. Do I need to configure something else? Since they are transferred as in-band I shouldn't.
Thank you in advance for your prompt reply.
The file transfer was not actually happening this is why the listener was listening but wa receiving nothing.
To send a file you need the full JID of the recipient. If you use smack, there is no physical XMPP client (like spark). In that case you use “Smack” or “Resource” (see here).
fileTransfer = fileTransferManager.createOutgoingFileTransfer(JidCreate.entityFullFrom(buddyJID + "/Smack")));
However, I still get an error:
XMPP error reply received from user002#localhost/Smack: XMPPError: not-allowed - cancel
and the file is not sent.
UPDATE: And of course the problem had nothing to do with smack. The issue was that the tool I have created was reading and writing to the same file, as a result, the file was erased and the error was because smack was requested to transfer an empty file. So, if you see this error, check the file you try to transfer first; it might have 0 bytes.

opc ua client implementation using eclipse milo

I am trying to do the implementation of opc ua client using eclipse milo sdk and the reference link am using is:
https://community.hortonworks.com/questions/176894/opc-ua-client-performance-with-eclipse-milo.html
for the Publish/Subscribe code since am having multiple nodes am not able to make out the data that I get corresponds to which node id and also the timestamp I am getting am not able to make out its in which format.
Item: org.eclipse.milo.opcua.sdk.client.subscriptions.OpcUaMonitoredItem#2b2c39b1
Value: DataValue{value=Variant{value=11}, status=StatusCode{name=Good, value=0x00000000, quality=good},
sourceTime=DateTime{utcTime=131771575305048867, javaDate=Fri Jul 27 15:02:10 IST 2018},
serverTime=DateTime{utcTime=131771575305048867, javaDate=Fri Jul 27 15:02:10 IST 2018}}
and when am using Async Read code am not getting timestamp.
[DataValue{value=Variant{value=3},
status=StatusCode{name=Good, value=0x00000000, quality=good}, sourceTime=DateTime{utcTime=0, javaDate=Mon Jan 01 05:30:00 IST 1601}, serverTime=DateTime{utcTime=0, javaDate=Mon Jan 01 05:30:00 IST 1601}},
DataValue{value=Variant{value=11}, status=StatusCode{name=Good, value=0x00000000, quality=good}, sourceTime=DateTime{utcTime=0, javaDate=Mon Jan 01 05:30:00 IST 1601},
serverTime=DateTime{utcTime=0, javaDate=Mon Jan 01 05:30:00 IST 1601}},
DataValue{value=Variant{value=8}, status=StatusCode{name=Good, value=0x00000000, quality=good},
sourceTime=DateTime{utcTime=0, javaDate=Mon Jan 01 05:30:00 IST 1601}, serverTime=DateTime{utcTime=0, javaDate=Mon Jan 01 05:30:00 IST 1601}}]
can anyone give me some idea on where am going wrong?
It might be easier to understand if you started with the examples from Milo itself, rather than a random benchmark someone wrote using Milo that you happened to stumble across.
Check out the examples:
Subscribe Example
Read Example

ews-java-api: Error on item update: At least one recipient isn't valid

I am working on a tool which uses ews-java-api to create, update and delete calendar items in Outlook agenda. It has been working fine, but now sometimes when it tries to update some calendar item, I get following error:
microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException: At least one recipient isn't valid., A message can't be sent because it contains no recipients.
at microsoft.exchange.webservices.data.core.response.ServiceResponse.internalThrowIfNecessary(ServiceResponse.java:278)
at microsoft.exchange.webservices.data.core.response.ServiceResponse.throwIfNecessary(ServiceResponse.java:267)
at microsoft.exchange.webservices.data.core.request.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:165)
at microsoft.exchange.webservices.data.core.ExchangeService.internalUpdateItems(ExchangeService.java:691)
at microsoft.exchange.webservices.data.core.ExchangeService.updateItem(ExchangeService.java:762)
at microsoft.exchange.webservices.data.core.service.item.Item.internalUpdate(Item.java:279)
at microsoft.exchange.webservices.data.core.service.item.Item.update(Item.java:400)
at be.vrt.quintiqexchange.main.QuintiqAdapter.insertUpdateCalendarItems(QuintiqAdapter.java:879)
at be.vrt.quintiqexchange.main.QuintiqAdapter.updateCalendarItems(QuintiqAdapter.java:796)
at be.vrt.quintiqexchange.main.QuintiqAdapter.run(QuintiqAdapter.java:286)
at java.lang.Thread.run(Thread.java:745)
Recently all the exchange accounts have been migrated from local Outlook servers to Office365 cloud servers. Maybe this has something to do with it? Or anybody have any idea on what is going wrong?
Following code is to perform the update for an item:
Item it = alitems.get(i);
...
it.update(ConflictResolutionMode.AlwaysOverwrite);
Following is the url being used to access office365 ews:
exchangewebservice = https://outlook.office365.com/EWS/Exchange.asmx
Thanks in advance
Edit: I use ews-java-api version 2.0
Edit: Here you can see that the error occurs on one line and than the next line, with the same recipient it doesn't occur...
microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException: At least one recipient isn't valid., A message can't be sent because it contains no recipients.
at microsoft.exchange.webservices.data.core.response.ServiceResponse.internalThrowIfNecessary(ServiceResponse.java:278)
at microsoft.exchange.webservices.data.core.response.ServiceResponse.throwIfNecessary(ServiceResponse.java:267)
at microsoft.exchange.webservices.data.core.request.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:165)
at microsoft.exchange.webservices.data.core.ExchangeService.internalUpdateItems(ExchangeService.java:691)
at microsoft.exchange.webservices.data.core.ExchangeService.updateItem(ExchangeService.java:762)
at microsoft.exchange.webservices.data.core.service.item.Item.internalUpdate(Item.java:279)
at microsoft.exchange.webservices.data.core.service.item.Item.update(Item.java:400)
at be.vrt.quintiqexchange.main.QuintiqAdapter.insertUpdateCalendarItems(QuintiqAdapter.java:880)
at be.vrt.quintiqexchange.main.QuintiqAdapter.updateCalendarItems(QuintiqAdapter.java:703)
at be.vrt.quintiqexchange.main.QuintiqAdapter.run(QuintiqAdapter.java:283)
at java.lang.Thread.run(Thread.java:745)
WARN be.vrt.quintiqexchange.main.QuintiqAdapter - At least one recipient isn't valid., A message can't be sent because it contains no recipients.by UPDATE for subject: on Thu Jun 23 14:00:00 CEST 2016 Thu Jun 23 19:00:00 CEST 2016 of user name.lastname#domain.com
INFO be.vrt.quintiqexchange.main.QuintiqAdapter - Appointment updated for subject: NIET DAG on Fri Aug 05 10:00:00 CEST 2016 Fri Aug 05 18:00:00 CEST 2016 of user name.lastname#domain.com
INFO be.vrt.quintiqexchange.main.QuintiqAdapter - Appointment updated for subject: PROEF st5 on Mon Aug 22 10:00:00 CEST 2016 Mon Aug 22 20:30:00 CEST 2016 of user name.lastname#domain.com
This means that the recipient isn't really the issue, I guess...
p.s. I replaced the original mailaddress but believe me, it's a correct mailadres :)
In my case, if the address is not properly trimmed and has any whitespace characters at all, EWS vomits this exception up.

Twitter4j issues with user's protected data

I am using twitter java api tweet4j in order to retrieve data from twitter users. I ve got a list of users ids from which I want to retrieve data. I read a list of string ids and I am trying to extract data via twitter java api into my database. However, some users has protection on their data. Thus, I am getting authentication errors, in some ids. Since my list is enormous, how is it possible to automatically create exceptions from user with no authentication right? Is there any method in twitter4j for protected or not protected users?
The error that I am getting:
Exception in thread "main" 401:Authentication credentials
(https://dev.twitter.com/pages/auth) were missing or incorrect. Ensure that you have
set valid consumer key/secret, access token/secret, and the system clock is in sync.
[Wed Apr 30 15:35:18 EEST 2014]date: Wed, 30 Apr 2014 12:36:58 GMT
[Wed Apr 30 15:35:18 EEST 2014]x-transaction: 0d6f0c50c647c52e
[Wed Apr 30 15:35:18 EEST 2014]pragma: no-cache
[Wed Apr 30 15:35:18 EEST 2014]cache-control: no-cache, no-store, must-revalidate, pre-
check=0, post-check=0
{"request":"\/1.1\/statuses\/user_timeline.json?
user_id=787323013&include_my_retweet=true&include_entities=true","error":"Not
authorized."}
[Wed Apr 30 15:35:18 EEST 2014]x-content-type-options: nosniff
[Wed Apr 30 15:35:18 EEST 2014]x-xss-protection: 1; mode=block
[Wed Apr 30 15:35:18 EEST 2014]x-rate-limit-limit: 180
Relevant discussions can be found on the Internet at:
[Wed Apr 30 15:35:18 EEST 2014]expires: Tue, 31 Mar 1981 05:00:00 GMT
http://www.google.co.jp/search?q=0742d262 or
http://www.google.co.jp/search?q=32729de5
[Wed Apr 30 15:35:18 EEST 2014]set-cookie: guest_id=v1%3A139886141837883092;
Domain=.twitter.com; Path=/; Expires=Fri, 29-Apr-2016 12:36:58 UTC
[Wed Apr 30 15:35:18 EEST 2014]set-cookie: lang=en
[Wed Apr 30 15:35:18 EEST 2014]www-authenticate: OAuth realm="https://api.twitter.com"
[Wed Apr 30 15:35:18 EEST 2014]content-length: 143
[Wed Apr 30 15:35:18 EEST 2014]x-rate-limit-reset: 1398862209
[Wed Apr 30 15:35:18 EEST 2014]server: tfe
[Wed Apr 30 15:35:18 EEST 2014]strict-transport-security: max-age=631138519
[Wed Apr 30 15:35:18 EEST 2014]x-access-level: read-write-directmessages
[Wed Apr 30 15:35:18 EEST 2014]{"request":"\/1.1\/statuses\/user_timeline.json?
user_id=787323013&include_my_retweet=true&include_entities=true","error":"Not
authorized."}
TwitterException{exceptionCode=[0742d262-32729de5], statusCode=401, message=null,
code=-1, retryAfter=-1, rateLimitStatus=RateLimitStatusJSONImpl{remaining=114,
limit=180, resetTimeInSeconds=1398862209, secondsUntilReset=890}, version=4.0.1}
at twitter4j.HttpClientImpl.handleRequest(HttpClientImpl.java:164)
at twitter4j.HttpClientBase.request(HttpClientBase.java:53)
at twitter4j.HttpClientBase.get(HttpClientBase.java:71)
at twitter4j.TwitterImpl.get(TwitterImpl.java:1968)
at twitter4j.TwitterImpl.getUserTimeline(TwitterImpl.java:156)
at twitter4j.TwitterImpl.getUserTimeline(TwitterImpl.java:177)
at twitter4j.examples.tweets.UpdateStatus.main(UpdateStatus.java:116)
You should catch the exception and continue processing, something like this:
for (long userId : userIds) { // presumably you have a list of users
try {
// call twitter4j here and process results
}
catch (TwitterException e) {
// do not throw if user has protected tweets, or if they deleted their account
if (e.getStatusCode() == HttpResponseCode.UNAUTHORIZED ||
e.getStatusCode() == HttpResponseCode.NOT_FOUND) {
// log something here
}
else {
throw e;
}
}
}

Categories

Resources