小编ans*_*tta的帖子

JmsTemplate没有发送超时

我有使用Spring 的IBM MQ jar配置的工作JMS 应用程序

它适用于正确的队列信息,但是当我给出错误的队列信息时

它挂在

LOG.info("SENDING MESSAGE");
jmsTemplate.send(this.getDestination(), messageCreator );  //here
Run Code Online (Sandbox Code Playgroud)

我的日志说发送消息,我正在处理 org.springframework.jmsexception ,但它不会抛出......我认为它在那时挂起。

我无法找到用于发送超时的 jmstemplate 的任何属性,仅用于接收超时...

这是app-context.xml中的jmstemplate conf (Spring)

<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate102">
        <property name="connectionFactory">
            <ref bean="jmsQueueConnectionFactory" />
        </property>
        <property name="destinationResolver">
            <ref bean="jmsDestinationResolver" />
        </property>
        <property name="pubSubDomain">
            <value>false</value>
        </property>
        <property name="receiveTimeout">
            <value>20000</value>

        </property>
Run Code Online (Sandbox Code Playgroud)

ibm mq conf -

<bean id="mqConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
        <property name="hostName">
            <value>${queue_hostname}</value>
        </property>
        <property name="port">
            <value>${queue_port}</value>
        </property>
        <property name="queueManager">
            <value>${queue_manager}</value>
        </property>
        <property name="channel">
            <value>${queue_channel}</value>
        </property>
        <property name="transportType">
            <value>1</value>
        </property>
    </bean>
Run Code Online (Sandbox Code Playgroud)

我已将其设置为自动确认 …

java spring jms jmstemplate ibm-mq

5
推荐指数
1
解决办法
9015
查看次数

为什么==在Long对象中产生true

在这段代码(story * 2) == tail中得到了True

falsedistance + 1 != tail.

== 检查参考,因为Long是不可变的,它对于两个不同的对象将是假的,

这里story * 2引用的值相等tail,但它们是两个不同的对象,而不是池的编译时常量.

   public class Test2 
{
         public static void main(String [] args) {

              Long tail = 2000L;
              Long distance = 1999L;
              Long story = 1000L;

                  System.out.println(tail > distance);

                  System.out.println((story * 2) == tail);

              if((tail > distance) ^ ((story * 2) == tail))
                  System.out.print("1");

              System.out.println(distance + 1 != tail);
              System.out.println((story * 2) == distance);

              if((distance + 1 …
Run Code Online (Sandbox Code Playgroud)

java immutability

4
推荐指数
1
解决办法
185
查看次数

C指针和临时变量

int main()  
{  
    int i=0;  
    int* p_numbers = ((int*) malloc (5*sizeof(int)));  
    int* temp;  
    temp = p_numbers;  
    for(i=0;i<5;i++)  
    {  
        *temp=i;   
        printf("temp %d p_numbers %d",*temp,*p_numbers);  
        temp++;           
    }
}
Run Code Online (Sandbox Code Playgroud)

请告诉分配给tempie 的指针temp=p_numbers.

temp不是指向指向的相同内存位置p_numbers

c memory pointers temp

2
推荐指数
1
解决办法
3943
查看次数

HashMap Entry类的recordAccess()方法是空体

API有这样的评论..

但是它做了什么?既然它有空身方法.

/**
 * This method is invoked whenever the value in an entry is
 * overwritten by an invocation of put(k,v) for a key k that's already
 * in the HashMap.
 */
void recordAccess(HashMap<K,V> m) {
}
Run Code Online (Sandbox Code Playgroud)

java collections hashmap

1
推荐指数
1
解决办法
520
查看次数

通用允许String对象作为整数

List listofinteger类型是Integer,但接受String对象当我做检查instance of Integer,这是给真正的,它太奇怪了,有谁能够解释发生了什么.

我只知道当我发送List listofinteger到方法,它被赋予参考列表中没有任何类型的引用变量,当我添加需要输入字符串,现在当我返回List listofanythingList of Integer type,就应该接受,因为它的参考.

现在,但我检查instanceof,这是印刷trueInteger,但它的String.

import java.util.ArrayList;
import java.util.List;

public class TestEx {

     List<Integer> listofinteger=new ArrayList<Integer>();      //list of integer type
     public static void main(String... args)
     {

         TestEx f=new TestEx();
         f.listofinteger.add(123);              //adds integer by wrapping it(auto)

         f.listofinteger=f.addelement(f.listofinteger);

         if(f.listofinteger.get(1) instanceof Integer);
         {
             System.out.println("true");                   //prints true here
             System.out.println(f.listofinteger.get(1));
         }



     }
      List<Integer> addelement(List listofanything)
     {
          listofanything.add("asdasdasd");            //adding String …
Run Code Online (Sandbox Code Playgroud)

java string generics integer list

0
推荐指数
1
解决办法
193
查看次数

简单的继承但令人困惑

这是JavaTest类

package testing.test;

public class JavaTest 
{
    int i=2;
}
Run Code Online (Sandbox Code Playgroud)

这是JavaTest2类,它扩展了JavaTest

package testing.test;

class JavaTest2 extends JavaTest
{
    public static void main(String[] args) {


        new JavaTest2().add(5);
    }

    void add(int i)
    {
        System.out.println(5+i);
    }
}
Run Code Online (Sandbox Code Playgroud)

现在输出到10,实际问题是得到父类的i值添加..

java

-3
推荐指数
1
解决办法
152
查看次数