Posts

Showing posts from 2018

Git Commands

GIT Status ======= git status git add . git commit -m "Updated README" git push

Creating Ignite Windows Service

Copy NSSM.exe under the bin folder Open command prompt and run the following commands   nssm install ignite-poc {{IGNIT_INSTALL_DIR}}\bin\ignite.bat nssm set ignite-poc AppDirectory {{IGNIT_INSTALL_DIR}} nssm set ignite-poc AppStdout {{IGNIT_INSTALL_DIR}}\logs\sysout.log nssm set ignite-poc AppStderr {{IGNIT_INSTALL_DIR}}\logs\syserr.log nssm set ignite-poc AppStdoutCreationDisposition 2 nssm set ignite-poc AppStderrCreationDisposition 2 nssm set ignite-poc AppStopMethodSkip 6

Apache CXF : How to expose endpoints as MBean using platform MBean server

Latest CXF versions use bus property settings to enable JMX but it is not well documented for the users. The following configuration enables CXF endpoints as MBean using the platform MBean server <core:bus>   <core:properties>          <entry key=" bus.jmx.enabled " value="true"/>   <entry key=" bus.jmx.usePlatformMBeanServer " value="true"/>   <entry key=" bus.jmx.createMBServerConnectorFactory " value="false"/>     </core:properties> </core:bus> The bus.jmx.enabled property enables the JMX bus.jmx.usePlatformMBeanServer tells CXF to use the platform MBean server, so if your JVM in webcontaienr has a rmi port enabled, then that port can be used to access the mbean. bus.jmx.createMBServerConnectorFactory  is by default true, in turn each JVM exposes the port 9914 port. so if you have more than one JVM configured in your server then there will be a port conflict. so to ...

Castor Marshalling error due to race condition (version 1.3.x)

If you are using Castor for Object to XML mapping, you may have encountered exceptions like  Nested error: org.exolab.castor.xml.MarshalException: White space is required between the processing instruction target and data.{File: [not available]; line: 1; column: 10} pool-1-thread-20org.castor.mapping.MappingUnmarshaller.loadMappingInternal(MappingUnmarshaller.java:282) org.castor.mapping.MappingUnmarshaller.getMappingLoader(MappingUnmarshaller.java:155) org.castor.mapping.MappingUnmarshaller.getMappingLoader(MappingUnmarshaller.java:130) org.exolab.castor.xml.Marshaller.setMapping(Marshaller.java:628) Original issue is the mapping file is being shared by many threads. To fix this we can use castor 1.4.X or consider creating ThreadLocal instances of   ThreadLocal <Mapping> localMapping = new ThreadLocal <Mapping>() { @Override protected Mapping initialValue() {                       ...

Processing redelivery of AMQP messages

Spring AMQP SimpleMessageListenerContainer (SMLC)  is session transacted,  it has a AckMode field whose default value is AUTO. AUTO Acknowledge ensures that if a message processing fails with an exception then it sends NACK and requeues the message back to queue. Your application may need to handle the retry logic, you just cant let a message fail forever (unless you have a requirement to not lose any message). Here is how you can handle it   Create a MessageListener class implementing the interface org.springframework.amqp.core.MessageListener. In its onMessage  check the basic property    boolean isRedelivered = amqpMessage . getMessageProperties (). getRedelivered ();    You can get the redelivery count from deliveryTag       long deliveryTag = amqpMessage .getMessageProperties(). getDeliveryTag ();  Now write your logic    if(deliveryTag >= maxRedeliveryCount) {        //Store ...