czwartek, sierpnia 21, 2014

What is the best JCA JMS Resource Adapter for JBoss 5.1, JBoss 7.1?

JMS JCA RA written by Frank Kieviet for SeeBeyond Technology Corporation and later developed at Sun Microsystems in JCAPS/OpenESB.

środa, sierpnia 20, 2014

GenericRa.rar with JBoss 5.1 and Oracle AQ


Generic JMS RA from Glassfish (created by Sun Microsystems, maintained by Oracle Corporation) is usable with Oracle AQ.

Adjust system properties:
oracle.jms.traceLevel=6
oracle.jms.useNativeXA=true
oracle.jms.useEmulatedXA=false
oracle.jms.j2eeCompliant=false.

<mbean code="org.jboss.jms.jndi.JMSProviderLoader"
          name="jboss.messaging:service=JMSProviderLoader,name=AQProvider">
      <attribute name="ProviderName">DefaultAQProvider</attribute>
      <attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
      <attribute name="FactoryRef">XAConnectionFactory</attribute>
      <attribute name="QueueFactoryRef">XAQueueConnectionFactory</attribute>
      <attribute name="TopicFactoryRef">XATopicConnectionFactory</attribute>
 <attribute name="Properties">
java.naming.factory.initial=oracle.jms.AQjmsInitialContextFactory
java.naming.security.principal=XA
java.naming.security.credentials=toortoor
db_url=jdbc:oracle:thin:@localhost:1521:XE
datasource=java:XAOracleDS
 </attribute>
   </mbean>

wtorek, sierpnia 19, 2014

ConnectionConsumer API for AQjmsConnection

public synchronized ConnectionConsumer createConnectionConsumer(
Destination destination, String s,
ServerSessionPool serversessionpool, int i) throws JMSException {
//AQjmsError.throwEx(102);
return _createConnectionConsumer(destination, null, s, serversessionpool, i);
}

private ConnectionConsumer _createConnectionConsumer(final Destination destination,
final String sub, final String s, final ServerSessionPool spool, final int max) {

return new ConnectionConsumer() {

private boolean closed = false;
private final LinkedBlockingQueue<Long> trigger = new LinkedBlockingQueue<Long>();
private AtomicLong counter = new AtomicLong(0);
@SuppressWarnings("unused")
private Thread bootstrapThread = bootstrapConsumers();

@Override
public ServerSessionPool getServerSessionPool() throws JMSException {
return spool;
}

@Override
public void close() throws JMSException {
closed = true;
}

public Thread bootstrapConsumers() {
Thread coordinator = new Thread() {
public void run() {
setName("ConsumerCoordinator "+Thread.currentThread().getId());
long lastCnt = 0;
while (!closed) {
Long value = null;
try {
value = trigger.poll(1, TimeUnit.SECONDS);
}
catch (InterruptedException e) {}
if ((value!=null && counter.get() < max) && !closed) {
Thread th = new Thread() {
public void run() {
runConsumer();
}
};
th.setDaemon(true);
th.start();
}
long currentCnt = counter.get();
if (currentCnt!=lastCnt) {
System.out.println("Server session pool #"+spool.hashCode()+" has got active "+counter.get()+" session(s), max is "+max);
lastCnt = currentCnt;
}
}
}
};
coordinator.setDaemon(true);
coordinator.start();
trigger.add(System.currentTimeMillis());
return coordinator;
}

public void runConsumer() {
Thread.currentThread().setName("Connection consumer "+Thread.currentThread().getId());
counter.incrementAndGet();
ServerSession ss = null;
Session sess = null;
MessageListener appSrvMessageListener = null;

while (!closed) {
try {
if (ss==null) {
ss = spool.getServerSession(); /* app srv will block */
trigger.put(System.currentTimeMillis());
sess = ss.getSession();
appSrvMessageListener = sess.getMessageListener();
}
if (sess==null) {
sess = ss.getSession();
}
sess.setMessageListener(null);
MessageConsumer mc = (sub!=null) ?
sess.createDurableSubscriber((Topic) destination, sub, s, false) :
sess.createConsumer(destination, s);

while (!closed) {
LinkedList list = new LinkedList();
int limit = 1; /* XA: one transaction per message */
for (int i=0; i < limit; i++) {
Message m = null;
try {
m = (i==limit-1) ? mc.receive(1000) : mc.receiveNoWait();
if (m!=null)
list.add(m);
}
catch (Exception e) {
System.out.println("Error while trying to receive message from JMS server, destination="+destination+", subscription="+sub+", selector="+s+": "+ e);
try {
sess.close();
}
catch (Exception ee) {}
sess = null;
break;
}
}
if (sess==null)
break;

if (!list.isEmpty()) {
synchronized (ss) {
for (Message m : list)
appSrvMessageListener.onMessage(m);
/*ss.start();*/
}
}
}
}
catch (Exception exception) {
System.out.println("Cannot consume JMS connection (but will retry), destination="+destination+", subscription="+sub+", selector="+s+": "+ exception);
try {
if (sess!=null)
sess.close();
}
catch (Exception e) {}
}
}
counter.decrementAndGet();
Logger.debug("EMS Connection Consumer closed (permanently), destination="+destination+", subscription="+sub+", selector="+s);
Logger.debug("Connection #"+hashCode()+" consumer counter is "+counter.get());
}
};
}

Oracle AQ XA Connection

There is a bug in aqapi.jar AQjmsGeneralDBConnection which prevents usage of XA outside Oracle WebLogic.

Here is a bugfix:

private String getProviderKey() throws JMSException {
try {
OracleConnection oracleconnection = (OracleConnection) m_dbConn;
+ if (oracleconnection==null)
+ oracleconnection = (OracleConnection) m_xaConn.getConnection();
String s = oracleconnection.getURL();
int i = s.indexOf('@');
String s1;
if (i < 0) {
if (!"jdbc:oracle:kprb:".equals(((Object) (s)))
&& !"jdbc:default:connection:".equals(((Object) (s))))
AQjmsError.throwEx(112);
s1 = "jdbc:oracle:kprb:";
} else {
s1 = s.substring(i);
}
return s1.toUpperCase();
} catch (SQLException sqlexception) {
throw new AQjmsException(sqlexception);
}
}

oracle.jms.traceLevel=6
oracle.jms.useNativeXA=true
oracle.jms.useEmulatedXA=false
oracle.jms.j2eeCompliant=true

execute dbms_aqadm.create_queue_table(queue_table => 'XA.JMS_Q_STORE001', queue_payload_type => 'sys.aq$_jms_message', multiple_consumers => false);
execute dbms_aqadm.create_queue(queue_name => 'XA.test_fw1', queue_table => 'XA.JMS_Q_STORE001');
execute dbms_aqadm.start_queue('XA.test_fw1')
@ActivationConfigProperty(propertyName = "destination", propertyValue = "Queues/test_fw1"),

czwartek, sierpnia 14, 2014

jbossts-properties.xml

<properties depends="arjuna" name="jta">
    <property name="com.arjuna.ats.jta.recovery.XAResourceRecovery.JBM01"  value="org.jboss.jms.server.recovery.MessagingXAResourceRecovery;java:DefaultJMSProvider"/>
    <property name="com.arjuna.ats.jta.recovery.XAResourceRecovery.EMS01"  value="org.jboss.jms.server.recovery.MessagingXAResourceRecovery;java:DefaultEMSProvider"/>
<property name="com.arjuna.ats.jta.recovery.XAResourceRecovery.Oracle" value="com.arjuna.ats.internal.jdbc.recovery.OracleXARecovery;oraclejta-properties.xml"/>
    <property name="com.arjuna.ats.jta.xaRecoveryNode" value="1"/>
</properties>

środa, sierpnia 13, 2014

Bardzo ładny Linux

ElementaryOS. Ładne czcionki, ładne kolory, kontrasty. Menedżer plików pamięta ostatnią lokalizację.


wtorek, sierpnia 12, 2014

MySQL to amatorska baza danych


Nowy Yaris

Auto miejskie dla pań nie powinno mieć ostrego i agresywnego wyglądu. Toyota naprawia błąd. Facelifting wprowadza krągłości oraz sporo wersji wyposażenia, od takiej bez klimatyzacji do takiej z dachem panoramicznym. Hybryda też ma szeroki zakres opcji. Jeżdżący po ulicach Yaris II to auto unikalne i kultowe. Pewnie VW Polo w topowej wersji ma nowocześniejsze technologie, ale poprawiony Yaris jest po prostu sympatyczny (tak jak druga generacja).






How to merge external context with JBoss global context

<mbean code="org.jboss.naming.ExternalContext" name="jboss.jndi:service=ExternalContext,jndiName=external/ems">
    <attribute name="JndiName">external/ems</attribute>
 <attribute name="Properties">
     java.naming.factory.initial=com.tibco.tibjms.CompanionContext
  java.naming.provider.url=external
  queues=test.bw1,test.fw1
  topics=topic1
 </attribute>
 <attribute name="InitialContext">com.tibco.tibjms.CompanionContext</attribute>
    <attribute name="RemoteAccess">true</attribute>
   </mbean>
   
   @Resource(mappedName = "external/ems/test.fw1", name = "external/ems/test.fw1")
 private Queue testFw1 = null;

//CompanionContext implements own lookup() methods

How to trace JBoss EJB property injection

package org.jboss.injection;

import java.util.Arrays;
import javax.naming.*;
import org.jboss.ejb3.BeanContext;
import org.jboss.ejb3.JndiUtil;
import org.jboss.injection.AbstractPropertyInjector;
import org.jboss.injection.PojoInjector;
import org.jboss.injection.lang.reflect.BeanProperty;
import org.jboss.logging.Logger;

public class JndiPropertyInjector extends AbstractPropertyInjector implements PojoInjector {

public JndiPropertyInjector(BeanProperty property, String jndiName,
Context ctx) {
super(property);
this.jndiName = jndiName;
this.ctx = ctx;
}

public void inject(BeanContext bctx) {
System.out.println("bctx="+bctx+", instance="+bctx.getInstance()+", jndi="+jndiName);
try {
inject(bctx, bctx.getInstance());
}
catch (Exception e) {
System.err.println("failed property="+property);
System.err.println("property="+property.getName());
}
}
        /* ... */
}

piątek, sierpnia 08, 2014

Małe duże kultowe auto









EMS 8.1 tibemsd.conf recommendations

EMS data files should be located on filesystem mounted with noatime!

network_thread_count = 8
flow_control = disabled
routing = disabled
xa_default_timeout = 300
destination_backlog_swapout = 3000
max_msg_memory = 5808MB
msg_pool_block_size = 4096
msg_swapping = enabled
reserve_memory = 64M
socket_send_buffer_size = 64K
socket_receive_buffer_size = 64K
logfile = primary.log
secondary_logfile = secondary.log
logfile_max_size = 10MB
statistics = enabled
rate_interval = 20
server_rate_interval = 20
max_stat_memory = 64MB
detailed_statistics = PRODUCERS,CONSUMERS
jre_option = -Xmx2g

client_heartbeat_server=10
server_heartbeat_server=10
server_heartbeat_client=10
ft_heartbeat=10
ft_activation=30
ft_reconnect_timeout=30
server_timeout_client_connection=60
client_timeout_server_connection=60
server_timeout_server_connection=60 (30 for hot-standby)

log_trace=DEFAULT,+ACL,+ADMIN,+CONFIG,-CONNECT,+CONNECT_ERROR,-DEST,+FLOW,+INFO,+LIMITS,+MEMORY,-MSG,-PRODCONS,+TX,+WARNING
console_trace=ADMIN,CONFIG

Java properties for EMS Push Provider:
ems.CONNECT_TIME=20000
ems.PING_TIME=40000
ems.WARN_TIME_NO_CONNECTION=60000
ems.FAIL_TIME_NO_CONNECTION=300000
ems.ELECTION_TIME=5000
ems.DEBUG=1
ems.NATIVE_MODE=0