[jboss-cvs] JBoss Messaging SVN: r7930 - in branches/Branch_1_4: src/main/org/jboss/jms/server and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jan 25 04:04:17 EST 2010
Author: gaohoward
Date: 2010-01-25 04:04:16 -0500 (Mon, 25 Jan 2010)
New Revision: 7930
Modified:
branches/Branch_1_4/integration/EAP4/etc/xmdesc/ServerPeer-xmbean.xml
branches/Branch_1_4/src/main/org/jboss/jms/server/ServerPeer.java
branches/Branch_1_4/src/main/org/jboss/messaging/core/impl/tx/TransactionRepository.java
Log:
JBMESSAGING-1772
Modified: branches/Branch_1_4/integration/EAP4/etc/xmdesc/ServerPeer-xmbean.xml
===================================================================
--- branches/Branch_1_4/integration/EAP4/etc/xmdesc/ServerPeer-xmbean.xml 2010-01-04 09:51:19 UTC (rev 7929)
+++ branches/Branch_1_4/integration/EAP4/etc/xmdesc/ServerPeer-xmbean.xml 2010-01-25 09:04:16 UTC (rev 7930)
@@ -441,14 +441,29 @@
<operation>
<description>
- list of all prepared transaction ids used for manual commit or rollback
+ display the information of all prepared transactions
</description>
<name>listPreparedTransactions</name>
- <return-type>java.util.List</return-type>
+ <return-type>java.lang.String</return-type>
</operation>
<operation>
<description>
+ display the details of a message
+ </description>
+ <name>showMessageDetails</name>
+ <parameter>
+ <description>
+ message id
+ </description>
+ <name>messageID</name>
+ <type>java.lang.Long</type>
+ </parameter>
+ <return-type>java.lang.String</return-type>
+ </operation>
+
+ <operation>
+ <description>
Commit a prepared transaction
</description>
<name>commitPreparedTransaction</name>
Modified: branches/Branch_1_4/src/main/org/jboss/jms/server/ServerPeer.java
===================================================================
--- branches/Branch_1_4/src/main/org/jboss/jms/server/ServerPeer.java 2010-01-04 09:51:19 UTC (rev 7929)
+++ branches/Branch_1_4/src/main/org/jboss/jms/server/ServerPeer.java 2010-01-25 09:04:16 UTC (rev 7930)
@@ -31,6 +31,8 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -60,8 +62,10 @@
import org.jboss.messaging.core.contract.Binding;
import org.jboss.messaging.core.contract.ClusterNotifier;
import org.jboss.messaging.core.contract.MemoryManager;
+import org.jboss.messaging.core.contract.Message;
import org.jboss.messaging.core.contract.MessageStore;
import org.jboss.messaging.core.contract.PersistenceManager;
+import org.jboss.messaging.core.contract.PersistenceManager.MessageChannelPair;
import org.jboss.messaging.core.contract.PostOffice;
import org.jboss.messaging.core.contract.Queue;
import org.jboss.messaging.core.contract.Replicator;
@@ -75,6 +79,7 @@
import org.jboss.messaging.core.impl.memory.SimpleMemoryManager;
import org.jboss.messaging.core.impl.message.SimpleMessageStore;
import org.jboss.messaging.core.impl.postoffice.MessagingPostOffice;
+import org.jboss.messaging.core.impl.tx.Transaction;
import org.jboss.messaging.core.impl.tx.TransactionRepository;
import org.jboss.messaging.util.ExceptionUtil;
import org.jboss.messaging.util.JMXAccessor;
@@ -1138,10 +1143,149 @@
{
return txRepository.getPreparedTransactions();
}
+
+ public String showMessageDetails(Long msgId) throws Exception
+ {
+ JBossStringBuilder buffer = new JBossStringBuilder();
+ buffer.append("<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\">");
+
+ buffer.append("<tr>");
+ buffer.append("<th>message_id</th>");
+ buffer.append("<th>expiration</th>");
+ buffer.append("<th>timestamp</th>");
+ buffer.append("<th>priority</th>");
+ buffer.append("<th>type</th>");
+ buffer.append("<th>headers</th>");
+ buffer.append("<th>payload</th>");
+ buffer.append("<th>payload type</th>");
+ buffer.append("</tr>");
+
+ List<Long> ids = new ArrayList<Long>();
+ ids.add(msgId);
+ List msgs = persistenceManager.getMessages(ids);
+ Iterator msgIter = msgs.iterator();
+ while (msgIter.hasNext())
+ {
+ Message m = (Message)msgIter.next();
+ buffer.append("<tr>");
+ buffer.append("<td>" + m.getMessageID() + "</td>");
+ buffer.append("<td>" + m.getExpiration() + "</td>");
+ buffer.append("<td>" + new Date(m.getTimestamp()) + "</td>");
+ buffer.append("<td>" + m.getPriority() + "</td>");
+ buffer.append("<td>" + m.getType() + "</td>");
+ buffer.append("<td>" + m.getHeaders() + "</td>");
+ buffer.append("<td>" + m.getPayload() + "</td>");
+ buffer.append("<td>" + m.getPayload().getClass().getName() + "</td>");
+ buffer.append("</tr>");
+ }
+
+ return buffer.toString();
+ }
- public List listPreparedTransactions()
+ public String listPreparedTransactions() throws Exception
{
- return txRepository.listPreparedTransactions();
+ JBossStringBuilder buffer = new JBossStringBuilder();
+ buffer.append("<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"1\">");
+
+ buffer.append("<tr>");
+ buffer.append("<th>transaction_id</th>");
+ buffer.append("<th>branch_qual</th>");
+ buffer.append("<th>format_id</th>");
+ buffer.append("<th>global_txid</th>");
+ buffer.append("<th>queue_name (channel_id)</th>");
+ buffer.append("<th>message_id (state)</th>");
+ buffer.append("</tr>");
+
+ List txs = txRepository.listPreparedTransactions();
+ Iterator ittx = txs.iterator();
+
+ while (ittx.hasNext())
+ {
+ Transaction tx = (Transaction)ittx.next();
+ Xid xid = tx.getXid();
+ long tid = tx.getId();
+ String stid = String.valueOf(tid);
+ String hexGlobalTxid = new String(xid.getGlobalTransactionId());
+ String hexBranchQual = new String(xid.getBranchQualifier());
+ String hexFormatId = String.valueOf(xid.getFormatId());
+
+ Map<String, List<String>> qInfo = new HashMap<String, List<String>>();
+
+ List msgList1 = persistenceManager.getMessageChannelPairRefsForTx(tid);
+ List msgList2 = persistenceManager.getMessageChannelPairAcksForTx(tid);
+
+ Iterator mIter1 = msgList1.iterator();
+ while (mIter1.hasNext())
+ {
+ MessageChannelPair pair = (MessageChannelPair)mIter1.next();
+ Binding binding = postOffice.getBindingForChannelID(pair.getChannelId());
+ String qname = binding.queue.getName();
+ Long chid = binding.queue.getChannelID();
+ String qkey = qname + " (" + chid + ")";
+ List<String> msgs = qInfo.get(qkey);
+ if (msgs == null)
+ {
+ msgs = new ArrayList<String>();
+ qInfo.put(qkey, msgs);
+ }
+ msgs.add(String.valueOf(pair.getMessage().getMessageID()) + " (+)");
+ }
+
+ Iterator mIter2 = msgList2.iterator();
+ while (mIter2.hasNext())
+ {
+ MessageChannelPair pair = (MessageChannelPair)mIter2.next();
+ Binding binding = postOffice.getBindingForChannelID(pair.getChannelId());
+ String qname = binding.queue.getName();
+ Long chid = binding.queue.getChannelID();
+ String qkey = qname + " (" + chid + ")";
+ List<String> msgs = qInfo.get(qkey);
+ if (msgs == null)
+ {
+ msgs = new ArrayList<String>();
+ qInfo.put(qkey, msgs);
+ }
+ msgs.add(String.valueOf(pair.getMessage().getMessageID()) + " (-)");
+ }
+
+ buffer.append("<tr>");
+ buffer.append("<td>" + stid + "</td>");
+ buffer.append("<td>" + hexBranchQual + "</td>");
+ buffer.append("<td>" + hexFormatId + "</td>");
+ buffer.append("<td>" + hexGlobalTxid + "</td>");
+
+ StringBuffer sbq = new StringBuffer();
+ StringBuffer sbm = new StringBuffer();
+
+ Iterator<String> itqs = qInfo.keySet().iterator();
+ while (itqs.hasNext())
+ {
+ String qname = itqs.next();
+ sbq.append(qname);
+
+ List<String> msgs = qInfo.get(qname);
+ for (String m : msgs)
+ {
+ sbq.append("<br/>");
+ sbm.append(m);
+ sbm.append("<br/>");
+ }
+ }
+
+ buffer.append("<td>");
+ buffer.append(sbq.toString());
+ buffer.append("</td>");
+
+ buffer.append("<td>");
+ buffer.append(sbm.toString());
+ buffer.append("</td>");
+
+ buffer.append("</tr>");
+ }
+
+ buffer.append("</table>");
+ return buffer.toString();
+
}
public boolean commitPreparedTransaction(Long transactionID)
Modified: branches/Branch_1_4/src/main/org/jboss/messaging/core/impl/tx/TransactionRepository.java
===================================================================
--- branches/Branch_1_4/src/main/org/jboss/messaging/core/impl/tx/TransactionRepository.java 2010-01-04 09:51:19 UTC (rev 7929)
+++ branches/Branch_1_4/src/main/org/jboss/messaging/core/impl/tx/TransactionRepository.java 2010-01-25 09:04:16 UTC (rev 7930)
@@ -567,15 +567,15 @@
return result;
}
- public List listPreparedTransactions()
+ public List<Transaction> listPreparedTransactions()
{
- ArrayList<String> list = new ArrayList<String>(map.size());
+ ArrayList<Transaction> list = new ArrayList<Transaction>(map.size());
Iterator itk = map.keySet().iterator();
while (itk.hasNext())
{
Xid txid = (Xid)itk.next();
Transaction tx = (Transaction)map.get(txid);
- list.add(tx.getId() + " : " + txid.toString());
+ list.add(tx);
}
return list;
}
More information about the jboss-cvs-commits
mailing list