I'm using JMS (Apache Qpid) to create connections to a message broker. I do create some connections and cache those in a Map (Map<String, Connection>). However, the message broker has its natural limits (in terms of resources like connections per user) which gets hit a some time. If I configure a connection via Qpid to use an idle timeout the connections in my map will constantly disconnect and connect again. Let's say the limit of connection is set to 3 and I create a 4th connection right in the moment when an idle timeout kicks in the 4th connection might connect and "steal" the connection. So the 4 connections will fight for the limit the message broker has. I've registered an exception listener and I do see the error occuring. I would like to close an connection on a specific error but it seems like I've no controll about that.
So how do I manage the lifecycle of a connection?
Is there a way to get information about if a connection is connected or not?
I believe you should add some meta-data to your ExceptionListener implementation in order to correlate it with the relevant connection. You could potentially use the same String value which you use in your Map<String, Connection>. You could also just set the Connection directly in your ExceptionListener implementation.
Aside from that you might reconsider creating multiple connections from your client in the first place. Generally speaking, one connection per client is sufficient. If you need to logically separate different tasks (e.g. producing & consuming) then you can create multiple sessions. This would have the benefit of simplifying your client application and using fewer resources on the broker.
Lastly, the JMS API doesn't provide any direct mechanism to test a connection's validity. In general it is safe to assume the connection is valid unless you receive an exception either synchronously or asynchronously via the ExceptionListener.
I also had same problem. As JMS specification have no method to get connection status, so you can use alternative method to get status
I use getClientID() to check connection status inside exception listener. If you take a look on implementation of getClientID() operation then you can see that they are first checking connection status and then providing connection ID
protected boolean isConnectionActive() {
boolean connectionStatus = false;
try {
String clientID = getConnection().getClientID();
connectionStatus = true;
} catch (Exception e) {
connectionStatus = false;
}
return connectionStatus; }
NOTE - this solution will definitely work upto latest library 0.55, but in future Qpid Team can change implementation of getClientID().
Related
There appears to be a difference in line numbers between macOS & PC lint baselines. Ultimately if either platform generates the baseline we end up with warnings on the other platform (PC generates the baseline - macOS has errors, and vice versa.)
macOS AS may even be wrong, even though it appears to work only for Mac when generated by Mac. I generated a new baseline from a PC and a new one from a Mac and compared them and saw some differences in the lines reported by baselines generated by Mac.
macOS Baseline Excerpt:
<issue
id="MissingSuperCall"
message="Overriding method should call `super.onBar`">
<location
file="foo.java"
line="955"
column="17"/>
</issue>
PC Baseline Excerpt:
<issue
id="MissingSuperCall"
message="Overriding method should call `super.onBar`">
<location
file="foo.java"
line="967"
column="17"/>
</issue>
The PC version appears to be correct in that onBar function from foo.java starts at 967, so why is macOS gradle lint reporting that error for the incorrect line 955? The errors in the Android Studio IDE on macOS are even represented correctly (shows that same lint error at 967). Right now its not practical to fix the amount of warnings this affects, so I need to create a baseline that's compatible with both platforms.
We're running the same Android Studio and runtime versions:
Android Studio Chipmunk | 2021.2.1 Patch 2
Runtime version: 11.0.12+7-b1504.28-7817840 amd64
Thanks!
I am using soap service configured using camel-cxf. The messages are sent into IBM MQ.
I get the below exception from the JMS consumer application when it trys to put the response into the reply queue.
The below exception is seen only after upgrading to camel 3.0.0
However, I don't see this issue before the upgrade where I was using
Camel version : 2.22.0
CXF version : 3.2.4
IBM MQ Version : 8.0.0.5
After the upgrade
Camel version : 3.0.0
CXF version : 3.3.6
IBM MQ Version : 8.0.0.5
There is no change in the IBM MQ Server version remains the same at 8.0.0.5.
Also, When I checked for the specific error, I understand that this issue happened in IBM MQ versions below 7 and had a fix in version 7.5
Refer this : PublishJMS processor failing for writing message to IBM Websphere MQ
In my usecase, the request-reply flow works when I degrade the camel version as mentioned above.
Should I manually, add the specific JMS Message Headers to the camel exchange object as part of camel 3, or is that some other change that I am missing. Please advice
EXCEPTION STACK
[cxf.services.dummyServiceNamePortType.RESP_OUT(performLogging:76)] RESP_OUT
Content-Type: text/xml
Headers: {JMS_IBM_Format=MQSTR , JMS_IBM_Character_Set=UTF-8, JMS_IBM_PutDate=20200401, JMSXDeliveryCount=1, JMS_IBM_MsgType=1, JMSXUserID=mqclient , JMS_IBM_Encoding=273, JMS_IBM_PutTime=14472875, JMSMessageType=text, JMS_IBM_PutApplType=28, JMSXAppID=exe }
WARN pool-3-thread-2 [apache.cxf.phase.PhaseInterceptorChain(doLog:475)] Interceptor for serviceName has thrown exception, unwinding now
java.lang.RuntimeException: JMSCC0051: The property 'JMS_IBM_MsgType' should be set using type 'java.lang.Integer', not 'java.lang.String'.
at org.apache.cxf.transport.jms.util.JMSUtil.convertJmsException(JMSUtil.java:98) ~[cxf-rt-transports-jms-3.3.4.jar:3.3.4]
at org.apache.cxf.transport.jms.BackChannelConduit.sendExchange(BackChannelConduit.java:123) ~[cxf-rt-transports-jms-3.3.4.jar:3.3.4]
at org.apache.cxf.transport.jms.MessageStreamUtil$SendingWriter.close(MessageStreamUtil.java:66) ~[cxf-rt-transports-jms-3.3.4.jar:3.3.4]
at java.io.FilterWriter.close(FilterWriter.java:104) ~[?:1.8.0_191]
at org.apache.cxf.ext.logging.LoggingOutInterceptor$LogEventSendingWriter.close(LoggingOutInterceptor.java:152) ~[cxf-rt-features-logging-3.3.4.jar:3.3.4]
at org.apache.cxf.transport.jms.MessageStreamUtil.closeStreams(MessageStreamUtil.java:89) ~[cxf-rt-transports-jms-3.3.4.jar:3.3.4]
at org.apache.cxf.transport.jms.BackChannelConduit.close(BackChannelConduit.java:72) ~[cxf-rt-transports-jms-3.3.4.jar:3.3.4]
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:63) ~[cxf-core-3.3.4.jar:3.3.4]
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) [cxf-core-3.3.4.jar:3.3.4]
at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:90) [cxf-core-3.3.4.jar:3.3.4]
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) [cxf-core-3.3.4.jar:3.3.4]
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) [cxf-core-3.3.4.jar:3.3.4]
at org.apache.cxf.transport.jms.JMSDestination.onMessage(JMSDestination.java:254) [cxf-rt-transports-jms-3.3.4.jar:3.3.4]
at org.apache.cxf.transport.jms.util.PollingMessageListenerContainer$Poller.run(PollingMessageListenerContainer.java:84) [cxf-rt-transports-jms-3.3.4.jar:3.3.4]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_191]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_191]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_191]
Caused by: com.ibm.msg.client.jms.DetailedMessageFormatException: JMSCC0051: The property 'JMS_IBM_MsgType' should be set using type 'java.lang.Integer', not 'java.lang.String'.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_191]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_191]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_191]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_191]
at com.ibm.msg.client.commonservices.j2se.NLSServices.createException(NLSServices.java:319) ~[com.ibm.mq.allclient-9.1.4.0.jar:9.1.4.0 - p914-L191119]
at com.ibm.msg.client.commonservices.nls.NLSServices.createException(NLSServices.java:226) ~[com.ibm.mq.allclient-9.1.4.0.jar:9.1.4.0 - p914-L191119]
at com.ibm.msg.client.jms.internal.JmsErrorUtils.createException(JmsErrorUtils.java:126) ~[com.ibm.mq.allclient-9.1.4.0.jar:9.1.4.0 - p914-L191119]
at com.ibm.msg.client.jms.internal.JmsMessageImpl.checkSettablePropertyName(JmsMessageImpl.java:2627) ~[com.ibm.mq.allclient-9.1.4.0.jar:9.1.4.0 - p914-L191119]
at com.ibm.msg.client.jms.internal.JmsMessageImpl.setStringProperty(JmsMessageImpl.java:1998) ~[com.ibm.mq.allclient-9.1.4.0.jar:9.1.4.0 - p914-L191119]
at com.ibm.jms.JMSMessage.setStringProperty(JMSMessage.java:1516) ~[com.ibm.mq.allclient-9.1.4.0.jar:9.1.4.0 - p914-L191119]
at org.apache.cxf.transport.jms.JMSMessageHeadersType.writeProp(JMSMessageHeadersType.java:390) ~[cxf-rt-transports-jms-3.3.4.jar:3.3.4]
at org.apache.cxf.transport.jms.JMSMessageHeadersType.writeTo(JMSMessageHeadersType.java:429) ~[cxf-rt-transports-jms-3.3.4.jar:3.3.4]
at org.apache.cxf.transport.jms.JMSMessageUtils.asJMSMessage(JMSMessageUtils.java:266) ~[cxf-rt-transports-jms-3.3.4.jar:3.3.4]
at org.apache.cxf.transport.jms.BackChannelConduit.send(BackChannelConduit.java:156) ~[cxf-rt-transports-jms-3.3.4.jar:3.3.4]
at org.apache.cxf.transport.jms.BackChannelConduit.sendExchange(BackChannelConduit.java:121) ~[cxf-rt-transports-jms-3.3.4.jar:3.3.4]
... 15 more
2020-04-01 16:47:29.407+0200 WARN pool-3-thread-2 [apache.cxf.phase.PhaseInterceptorChain(doLog:475)] Interceptor for serviceName has thrown exception, unwinding now
org.apache.cxf.binding.soap.SoapFault: Error writing to XMLStreamWriter.
at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor$SoapOutEndingInterceptor.handleMessage(SoapOutInterceptor.java:318) ~[cxf-rt-bindings-soap-3.3.4.jar:3.3.4]
at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor$SoapOutEndingInterceptor.handleMessage(SoapOutInterceptor.java:294) ~[cxf-rt-bindings-soap-3.3.4.jar:3.3.4]
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) ~[cxf-core-3.3.4.jar:3.3.4]
at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:112) ~[cxf-core-3.3.4.jar:3.3.4]
at org.apache.camel.component.cxf.CxfConsumer.lambda$createServer$0(CxfConsumer.java:83) ~[camel-cxf-3.0.0.jar:3.0.0]
at org.apache.cxf.phase.PhaseInterceptorChain.wrapExceptionAsFault(PhaseInterceptorChain.java:374) [cxf-core-3.3.4.jar:3.3.4]
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:332) [cxf-core-3.3.4.jar:3.3.4]
at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:90) [cxf-core-3.3.4.jar:3.3.4]
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) [cxf-core-3.3.4.jar:3.3.4]
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) [cxf-core-3.3.4.jar:3.3.4]
at org.apache.cxf.transport.jms.JMSDestination.onMessage(JMSDestination.java:254) [cxf-rt-transports-jms-3.3.4.jar:3.3.4]
at org.apache.cxf.transport.jms.util.PollingMessageListenerContainer$Poller.run(PollingMessageListenerContainer.java:84) [cxf-rt-transports-jms-3.3.4.jar:3.3.4]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_191]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_191]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_191]
Caused by: javax.xml.stream.XMLStreamException: No open start element, when trying to write end element
at com.ctc.wstx.sw.BaseStreamWriter.throwOutputError(BaseStreamWriter.java:1584) ~[woodstox-core-5.0.3.jar:5.0.3]
at com.ctc.wstx.sw.BaseStreamWriter.reportNwfStructure(BaseStreamWriter.java:1613) ~[woodstox-core-5.0.3.jar:5.0.3]
at com.ctc.wstx.sw.BaseNsStreamWriter.doWriteEndTag(BaseNsStreamWriter.java:664) ~[woodstox-core-5.0.3.jar:5.0.3]
at com.ctc.wstx.sw.BaseNsStreamWriter.writeEndElement(BaseNsStreamWriter.java:291) ~[woodstox-core-5.0.3.jar:5.0.3]
at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor$SoapOutEndingInterceptor.handleMessage(SoapOutInterceptor.java:304) ~[cxf-rt-bindings-soap-3.3.4.jar:3.3.4]
... 14 more
I wonder if someone can share their best setup for Golang using Vscode on Mac. As I am continously having issues such as:
sometimes gomft doesn't work.
Functions defined in the same package shows with a red underline warning saying it's not defined (but works when running it)
having the following message popped up
Your workspace is misconfigured: command-line-arguments has no metadata. Please see https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md for more information or file an issue (https://github.com/golang/go/issues/new) if you believe this is a mistake.
Here are some information of my go setup:
Version: go1.13.4 darwin/amd64
Settings in 'settings.json':
{
"window.zoomLevel": 1,
"workbench.iconTheme": "material-icon-theme",
"editor.accessibilitySupport": "off",
"go.useLanguageServer": true,
"go.formatTool": "gofmt",
"go.lintTool": "golangci-lint",
"[go]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
},
"explorer.confirmDragAndDrop": false,
"javascript.updateImportsOnFileMove.enabled": "always",
"diffEditor.ignoreTrimWhitespace": false
}
GOPATH is pointing to the folder where Go is installed
you can try this setting.
"go.inferGopath": false,
"go.buildOnSave": "workspace",
"go.lintOnSave": "package",
"go.vetOnSave": "package",
"go.buildTags": "",
"go.buildFlags": [],
"go.lintFlags": [],
"go.vetFlags": [],
"go.coverOnSave": false,
"go.useCodeSnippetsOnFunctionSuggest": false,
"go.formatTool": "goreturns",
"go.gocodeAutoBuild": false,
"go.useLanguageServer": true,
"go.alternateTools": {
"go-langserver": "gopls",
},
"go.languageServerExperimentalFeatures": {
"format": true,
"autoComplete": true
},
"[go]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
},
go.useLanguageServer: false, may help you
I'm seeing the same problem and also using golangci-lint for a lint tool. When I look at the output from the Go extension (View > Command Pallet > Output: Focus on Output View; then choose "Go" in the dropdown for the output view), I see errors like this:
Error while running tool: /usr/local/bin/golangci-lint run --print-issued-lines=false
level=warning msg="[runner] Can't run linter goanalysis_metalinter: assign: failed prerequisites: inspect#example.com/pkg/example"
And this
level=error msg="Running error: buildssa: analysis skipped: errors in package: [/Users/tschaub/projects/pkg/example.go:6:15: undeclared name: SomethingIJustStartedTyping
The first error (assign: failed prerequisites) was ticketed in https://github.com/golangci/golangci-lint/issues/827 and closed with a comment about updating to golangci-lint#v1.24.0.
The second error (buildssa: analysis skipped) was ticketed in https://github.com/golangci/golangci-lint/issues/896 and is receiving new comments as I type this.
Upgrading to v1.24.0 may not solve the issue, but it sounds like it might generate more descriptive output.
Even using golangci-lint#v1.24.0 doesn't fix the problem for me. I need to quit VSCode and restart it whenever I get in this "misconfigured" state. I'm hoping that after tools catch up with go modules, things will be a bit more stable/reliable.
I want to do a ping to 10.20.88.33 - 1 = 10.20.88.32 (gateway IP). How can i write a script to do from below output ?, should sort and ignore same AS (autonomous number) from 3rd column to get Neighbor state IP.
In the below output neighbor state IPs 10.20.88.19 & 10.20.88.20 contains same AS number, so the gateway is 10.20.88.33 - 1 (gateway is always -1 IP from last prefix of neighbor state IP).
Help to me to create a script to do this ?
186590d10b29:~ prabhapr$ cat 1.txt
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
10.20.88.19 4 65006 68570 68090 2638 0 0 3d04h 429
10.20.88.20 4 65006 68579 68091 2638 0 0 3d04h 429
10.20.88.33 4 64800 9128 8999 2638 0 0 10:13:41 418
I developed a windows phone 8.1 app and I want to add Google ad mob adds to it. I followed the instructions in this link I added GoogleAds.dll to my Windows phone 8.1 references but in tools I dint find AdView control. I am using VS2013 express.
I tried through C# code too.
{
AdView bannerAd = new AdView
{
Format = AdFormats.BANNER,
AdUnitID = "MY_AD_UNIT_ID"
};
AdRequest adRequest = new AdRequest();
_mygrid.Children.Add(bannerAd);
bannerAd.LoadAd(adRequest);
}
where _mygrid is a grid. can I add the Adview controller to Grid ?
When I try to build the solution I am getting following errors
Error 1 The type 'System.Windows.Controls.UserControl' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Windows, Version=2.0.6.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. c:\users\makot\documents\visual studio 2013\Projects\WC\WC\MainPage.xaml.cs
Error 2 The best overloaded method match for 'Windows.UI.Xaml.Controls.UIElementCollection.Add(Windows.UI.Xaml.UIElement)' has some invalid arguments c:\users\makot\documents\visual studio 2013\Projects\WC\WC\MainPage.xaml.cs
Error 3 Argument 1: cannot convert from 'GoogleAds.AdView' to 'Windows.UI.Xaml.UIElement' c:\users\makot\documents\visual studio 2013\Projects\WC\WC\MainPage.xaml.cs
Google Ad mob SDK currently supports Silverlight (WP8/WP8.1 Silverlight) only. Although you can reference the mentioned dll to a WP8.1 RT project, it doesn't work.