У меня исключение неизвестного хоста для кода ниже.Я не уверен, что не так с кодом.
@Component
@Configuration
public class RabbitListenerContainerFactory {
static final Logger logger = LoggerFactory.getLogger(RabbitListenerContainerFactory.class);
@Autowired
RabbitMqConfig rabbitMqConfig;
@Autowired
EPPQ2Subscriber receiver;
@Autowired
EPPQ2ChanelAwareSubscriber receiverChanel;
public RabbitListenerContainerFactory(ConfigurableApplicationContext ctx) {
printContainerStartMsg();
}
private void printContainerStartMsg() {
logger.info("----------- Scrubber Container Starts --------------");
}
@Bean
public SimpleMessageListenerContainer queueListenerContainer(ConnectionFactory connectionFactory,
MessageListenerAdapter listenerAdapter) {
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory);
container.setQueueNames(rabbitMqConfig.getSubscriberQueueName());
// container.setQueueNames("SampleQueue"); /*This just for testing.. !*/
container.setMessageListener(listenerAdapter);
container.setAcknowledgeMode(AcknowledgeMode.MANUAL);
container.setDeclarationRetries(5);// This is default to 3, We can twick this and move this to prop
container.setPrefetchCount(100); //Tell the broker how many messages to send to each consumer in a single request.
return container;
}
@Bean
MessageListenerAdapter listenerAdapter(EPPQ2Subscriber receiver) {
return new MessageListenerAdapter(receiver, "receiveMessage");
}
/*@Bean
MessageListenerAdapter listenerAdapterWithChanel(EPPQ2ChanelAwareSubscriber receiverChanel) {
return new MessageListenerAdapter(receiverChanel);
}*/
@Bean
ConnectionFactory connectionFactory () {
final CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
connectionFactory.setAddresses(Arrays.toString(rabbitMqConfig.getSubscriberHosts()));
//connectionFactory.setHost(Arrays.toString(rabbitMqConfig.getSubscriberHosts()));
connectionFactory.setVirtualHost("hydra.services");
connectionFactory.setPort(rabbitMqConfig.getSubscriberPort());
connectionFactory.setUsername(rabbitMqConfig.getSubscriberUsername());
connectionFactory.setPassword(rabbitMqConfig.getSubscriberPassword());
return connectionFactory;
}
}
Я вижу, что на хосте работает кролик. Здесь я вижу консоль администратора http://hostname:15672/ Tel net работает Telnet hostname15672
тайм-аут 3 bash -c 'cat </ dev / null> / dev / tcp / hostname / 15672';echo $?
Вот журнал:
org.springframework.amqp.AmqpIOException: java.net.UnknownHostException:host-name
Редактировать 1
public class RabbitMqConfig {
private String [] subscriberHosts;
private int subscriberPort;
private String [] publisherHosts;
private int publisherPort;
private String subscriberUsername;
private String subscriberPassword;
private String publisherUsername;
private String publisherPassword;
private String subscriberQueueName;
private String publisherQueueName;
private String publisherTopic;
private String routingKey;
/**
*
* @return -read queue hosts
*/
public String[] getSubscriberHosts() {
return subscriberHosts;
}
/**
*
* @return -read queue port
*/
public int getSubscriberPort() {
return subscriberPort;
}
/**
*
* @return -write queue hosts
*/
public String[] getPublisherHosts() {
return publisherHosts;
}
/**
*
* @return -write queue port
*/
public int getPublisherPort() {
return publisherPort;
}
/**
*
* @return -Read Queue user name
*/
public String getSubscriberUsername() {
return subscriberUsername;
}
/**
*
* @return Read Queue password
*/
public String getSubscriberPassword() {
return subscriberPassword;
}
/**
*
* @return -Write Queue user name
*/
public String getPublisherUsername() {
return publisherUsername;
}
/**
*
* @return -Write Queue password
*/
public String getPublisherPassword() {
return publisherPassword;
}
/**
*
* @return -Write Queue name
*/
public String getSubscriberQueueName() {
return subscriberQueueName;
}
/**
*
* @return --Read Queue name
*/
public String getPublisherQueueName() {
return publisherQueueName;
}
/**
*
* @return
*/
public String getPublisherTopic() {
return publisherTopic;
}
/**
*
* @return
*/
public String getRoutingKey() {
return routingKey;
}
@PostConstruct
public void getAIMCredentails() {
tempApiCallMock();
}
private void tempApiCallMock() {
String [] host = {"10.30.190.25"};
this.subscriberHosts = host;
this.subscriberPort = 5672;
this.subscriberQueueName = "hydra.Syphon.q1";
this.subscriberUsername = "dftp_subscriber";
this.subscriberPassword = "dftp_subscriber";
this.publisherHosts = host;
this.publisherPort = 5672;
this.publisherUsername = "dftp_publisher";
this.publisherPassword = "dftp_publisher";
}
Спасибо, что поправили меня, я изменил порт на 5672 Новсе та же проблема.и мой telnet host 5672 работает