我确实看到了很多与此相关的帖子并尝试了建议的解决方案(我已经关注了一个)。 我正在运行一个弹簧启动应用程序,它有来自AMQ的春季批次和骆驼路线。该应用程序不会在我们的独立Linux机器上终止,除非我们专门关闭它。但是在另一个在2个不同的Linux机箱上进行多节点设置的环境(没有集群)但是通过Spring云连接的其他环境之后,eureka在运行了几个小时后突然停机。此外,我尝试查看日志,我没有看到任何错误。 我无法弄清楚可能是根本原因。有没有人知道为什么会发生这样的事情?
的pom.xml
static void Main(string[] args)
{
bool quit = false;
Random random = new Random();
int randomNumber = random.Next(1, 10);
Console.WriteLine("You are now playing 'Guess a Number'! The number is going to draw randomly from the range of 1 - 10. Enter the number you think the console drew and you have five chances to guess! Good luck!");
List<int> num = new List<int>();
int guesses = 5;
while (!quit)
{
string playerGuess = Console.ReadLine();
int oneNum;
if (int.TryParse(playerGuess, out oneNum))
{
num.Add(oneNum);
}
var lastNum = num.Last();
if (guesses == 0) //the guesses times should be checked first.
{
Console.WriteLine("Sorry, you have no more guesses.");
break;
}
if (lastNum < randomNumber)//the list's last element was your input number.
{
guesses--;
Console.WriteLine("The number you entered is smaller than the random number, you have {0} chances left.", guesses);
}
if (lastNum > randomNumber)
{
guesses--;
Console.WriteLine("The number you entered is bigger than the random number, you have {0} chances left.", guesses);
}
if (lastNum==randomNumber)//if equals
{
quit = true;//set the flag to end loop
Console.WriteLine("Congratulations! You have guessed the right number!");
}
}
Console.ReadKey();
}
申请类
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.my.org</groupId>
<artifactId>my-proj</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>my-proj</name>
<description>My Project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<ml.jersey.version>1.17</ml.jersey.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Camden.SR5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-dependencies</artifactId>
<version>2.19.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-client</artifactId>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>runtime</scope>
</dependency>
<!-- MarkLogic -->
<dependency>
<groupId>com.marklogic</groupId>
<artifactId>marklogic-client-api</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>${ml.jersey.version}</version><!--$NO-MVN-MAN-VER$ -->
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-apache-client4</artifactId>
<version>${ml.jersey.version}</version><!--$NO-MVN-MAN-VER$ -->
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>${ml.jersey.version}</version><!--$NO-MVN-MAN-VER$ -->
</dependency>
<!-- Camel -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
</dependency>
<!-- ActiveMQ -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-camel</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-pool</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
启动脚本
package com.my.org;
import javax.jms.ConnectionFactory;
import org.apache.activemq.camel.component.ActiveMQComponent;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
public class MyBatchApplication {
public static void main(String[] args) {
SpringApplication.run(MyBatchApplication.class, args);
}
@Bean(name = "activemq")
public ActiveMQComponent createComponent(ConnectionFactory factory) {
ActiveMQComponent activeMQComponent = new ActiveMQComponent();
activeMQComponent.setConnectionFactory(factory);
return activeMQComponent;
}
@Bean
public MarkLogicClient markLogicClient() {
return new MarkLogicJavaClientImpl();
}
}