[
https://issues.apache.org/jira/browse/QPID-7256?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15277891#comment-15277891
]
Steven commented on QPID-7256:
------------------------------
as I cannot attach any attachment,the source_code of test code is below:
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.ExceptionListener;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
/**
* After change connection initial and will throw exception sometimes
*
* @author Steven
*/
public class Hello_BeforeChange {
public Hello_BeforeChange() {
}
public static void main(String[] args) {
Hello_BeforeChange hello = new Hello_BeforeChange();
for (int i = 0; i < 1000; i++) {
hello.runTest();
System.out.println("message " + i + " sent.");
}
}
private Context getContext() {
Context context = null;
try {
InputStream resourceAsStream =
this.getClass().getResourceAsStream("hello.properties");
Properties properties = new Properties();
properties.load(resourceAsStream);
context = new InitialContext(properties);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return context;
}
private void runTest() {
Session session = null;
Connection connection = null;
Context context = null;
try {
context = this.getContext();
ConnectionFactory connectionFactory = (ConnectionFactory)
context.lookup("qpidConnectionfactory");
connection = connectionFactory.createConnection();
connection.setExceptionListener(new ExceptionListener()
{
@Override
public void onException(JMSException exception)
{
System.out.println("ssssssssssssssssssssssssssssssssssssssss");
}
});
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = (Queue) context.lookup("queue");
MessageProducer messageProducer = session.createProducer(queue);
TextMessage message = session.createTextMessage("Hello world!");
messageProducer.send(message);
} catch (Exception exp) {
try {
if (session != null) {
session.close();
}
if (connection != null) {
connection.stop();
connection.close();
}
} catch (JMSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
exp.printStackTrace();
}
}
}
> When invoke the method "connection.start" in a loop,reporting socket closed
> ---------------------------------------------------------------------------
>
> Key: QPID-7256
> URL: https://issues.apache.org/jira/browse/QPID-7256
> Project: Qpid
> Issue Type: Bug
> Components: Java Client
> Affects Versions: 0.32
> Environment: windows7、 jdk7
> Reporter: Steven
>
> I use the for loop,It will loop 1000 times,every time,I create a
> connection,then send message,After the message has been sent,close the
> connection.
> this loop executed it for some times,It will report error,as you can see the
> screen shot
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]