paulwong

#

Guide to the Most Important JVM Parameters

https://www.baeldung.com/jvm-parametersa

Optimising Your Minecraft: Jvm Arguments
https://xealgaming.net/threads/optimising-your-minecraft-jvm-arguments.4758/

posted @ 2019-08-01 16:55 paulwong 阅读(97) | 评论 (0)编辑 收藏

JVM内存配置

JVM内存主要分为两个部分,分别是PermanentSapce和HeapSpace。

PermantSpace主要负责存放加载的Class类级对象如class本身,method,field等反射对象,一般不用配置。

JVM的Heap区可以通过-X参数来设定。HeapSpace= {Old + NEW {= Eden , from, to } }

当一个URL被访问时,内存申请过程如下:

  1. JVM会试图为相关Java对象在Eden中初始化一块内存区域 
  2. 当Eden空间足够时,内存申请结束。否则到下一步 
  3. JVM试图释放在Eden中所有不活跃的对象(这属于1或更高级的垃圾回收), 释放后若Eden空间仍然不足以放入新对象,则试图将部分Eden中活跃对象放入Survivor区
  4.  Survivor区被用来作为Eden及OLD的中间交换区域,当OLD区空间足够时,Survivor区的对象会被移到Old区,否则会被保留在Survivor区 
  5. 当OLD区空间不够时,JVM会在OLD区进行完全的垃圾收集(0级) 
  6. 完全垃圾收集后,若Survivor及OLD区仍然无法存放从Eden复制过来的部分对象,导致JVM无法在Eden区为新对象创建内存区域,则出现”out of memory错误”

Xms/Xmx:定义NEW+OLD段的总尺寸,ms为JVM启动时NEW+OLD的内存大小;mx为最大可占用的NEW+OLD内存大小。。在用户生产环境上一般将这两个值设为相同,以减少运行期间系统在内存申请上所花的开销; 

NewSize/MaxNewSize:定义单独NEW段的尺寸,NewSize为JVM启动时NEW的内存大小;MaxNewSize为最大可占用的NEW的内存大小。在用户生产环境上一般将这两个值设为相同,以减少运行期间系统在内存申请上所花的开销;

Xms/Xmx和NewSize/MaxNewSize定义好后,OLD区间也自然定义完毕了,即OLD区初始大小=(Xms-NewSize),OLD区最大可占用大小=(Xmx-MaxNewSize); 

PermSize/MaxPermSize:定义Perm段的尺寸,PermSize为JVM启动时Perm的内存大小;MaxPermSize为最大可占用的Perm内存大小。在用户生产环境上一般将这两个值设为相同,以减少运行期间系统在内存申请上所花的开销。

posted @ 2019-08-01 16:44 paulwong 阅读(144) | 评论 (0)编辑 收藏

使用 Awaitility 测试异步代码

自动化工具 异步校验工具 awaitility 快速入门
https://testerhome.com/topics/7408


https://yanbin.blog/test-asyn-call-with-awaitility/

Introduction to Awaitlity
https://www.baeldung.com/awaitlity-testing




posted @ 2019-08-01 10:06 paulwong 阅读(200) | 评论 (0)编辑 收藏

Spring Batch JUnit test for multiple jobs


https://stackoverflow.com/questions/34217101/spring-batch-junit-test-for-multiple-jobs

@Configuration
public class TestBatchConfiguration implements MergedBeanDefinitionPostProcessor {

    @Autowired
    @Qualifier("JobA")
    private Job job;

    @Bean(name="jtestl")
    public JobLauncherTestUtils jobLauncherTestUtils() {
        JobLauncherTestUtils jobLauncherTestUtils = new JobLauncherTestUtils();
        jobLauncherTestUtils.setJob(job);
        return jobLauncherTestUtils;
    }

    /**
     * 
https://stackoverflow.com/questions/22416140/autowire-setter-override-with-java-config
     * This is needed to inject the correct job into JobLauncherTestUtils
     
*/
    @Override
    public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) {
        if(beanName.equals("jtestl")) {
            beanDefinition.getPropertyValues().add("job", getMyBeanFirstAImpl());
        }
    }

    private Object getMyBeanFirstAImpl() {
        return job;
    }

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }
}

posted @ 2019-07-31 10:48 paulwong 阅读(228) | 评论 (0)编辑 收藏

Keep SSH session alive

sshd (the server) closes the connection if it doesn't hear anything from the client for a while. You can tell your client to send a sign-of-life signal to the server once in a while.

The configuration for this is in the file "~/.ssh/config", create it if the configuration file does not exist. To send the signal every four minutes (240 seconds) to the remote host, put the following in your "~/.ssh/config" file.

Host remotehost:     HostName remotehost.com     ServerAliveInterval 240 

This is what I have in my "~/.ssh/config":

To enable it for all hosts use:

Host * ServerAliveInterval 240 

Also make sure to run:

chmod 600 ~/.ssh/config 

because the config file must not be world-readable.

posted @ 2019-07-30 13:46 paulwong 阅读(96) | 评论 (0)编辑 收藏

publish over ssh 实现 Jenkins 远程部署

Jenkins远程部署,一开始没有任何头绪,想了很多方案. 因为两台机器都是windows系统,所以想到publish over cifs, 但是这个网上资料太少,貌似只能内网使用。又想到了Jenkins 分布式构建,但是Jenkins构建的代码和产物最后自动拷贝到主节点。而远程机器其实是客户方的机器,所以这个分布式构建并不适用。最后还是选定publish over ssh来实现远程部署。 
请注意:在进行远程部署操作前,先要确保客户机能ssh 登录到远程机器。如果不知道SSH怎么登陆,请参考http://blog.csdn.net/flyingshuai/article/details/72897692 
1. 安装publish over ssh 插件,安装很简单,在此不表。 
2. 在Jenkins系统设置里找到Publish over SSH模块 
3. 用户名/密码方式登录的,系统设置里设置如下: 
4. 如果是证书登录的,系统设置里设置如下: 
5. Job设置,点击增加构建后操作步骤,选择send build artifacts over ssh, 设置如下: 
6. 文件上传到远程服务器后,还有一些后续操作,比如,替换数据库配置文件。可以把bat命令写到一个批处理文件中,存到服务器上。Exec command填写批处理文件的绝对路径。如上图所示。
关于bat脚本: 
如果每次都需要替换同样的文件,用copy /y 是无条件覆盖,不会询问。而xcopy可以实现批量拷贝文件和文件夹。如果文件较多可用此命令 
注意脚本运行失败,构建也会显示蓝色成功图标,所以一定要打开控制台输出,看是否真的成功。
--------------------- 
作者:flyingshuai 
来源:CSDN 
原文:https://blog.csdn.net/flyingshuai/article/details/72898665 
版权声明:本文为博主原创文章,转载请附上博文链接!

posted @ 2019-07-25 09:33 paulwong 阅读(202) | 评论 (0)编辑 收藏

How do I clear my Jenkins/Hudson build history?

     摘要: 问题:I recently updated the configuration of one of my hudson builds. The build history is out of sync. Is there a way to clear my build history?Please and thank you回答1:If you click Manage Hudson / Relo...  阅读全文

posted @ 2019-07-24 16:18 paulwong 阅读(118) | 评论 (0)编辑 收藏

Springboot ActiveMQ jmsTemplate配置

@Configuration
@DependsOn(value="cachingConnectionFactory")
public class JmsTemplateConfiguration {

@Value("${wechat.sendmessage.queue}")
private String queueName;

@Value("${wechat.sendmessage.topic}")
private String topicName;

@Value("${spring.jms.pub-sub-domain}")
private boolean isPubSubDomain;


/**
 * 定义点对点队列
 * 
@return
 
*/
@Bean
public Queue queue() {
    return new ActiveMQQueue(queueName);
}



/**
 * 定义一个主题
 * 
@return
 
*/
@Bean
public Topic topic() {
    return new ActiveMQTopic(topicName);
}

private final ObjectProvider<DestinationResolver> destinationResolver;
private final ObjectProvider<MessageConverter> messageConverter;
private final CachingConnectionFactory cachingConnectionFactory;

@Autowired
public JmsTemplateConfiguration(ObjectProvider<DestinationResolver> destinationResolver,
                                ObjectProvider<MessageConverter> messageConverter,
                                CachingConnectionFactory cachingConnectionFactory) {
    this.destinationResolver = destinationResolver;
    this.messageConverter = messageConverter;
    this.cachingConnectionFactory = cachingConnectionFactory;
}

/**
 * 配置队列生产者的JmsTemplate
 * 
@return JmsTemplate
 
*/
@Bean(name="jmsQueueTemplate")
public JmsTemplate jmsQueueTemplate() {
    //设置创建连接的工厂
    
//JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory);
    
//优化连接工厂,这里应用缓存池 连接工厂就即可
    JmsTemplate jmsTemplate = new JmsTemplate(cachingConnectionFactory);
    //设置默认消费topic
   
//jmsTemplate.setDefaultDestination(topic());
    
//设置P2P队列消息类型
    jmsTemplate.setPubSubDomain(isPubSubDomain);

    DestinationResolver destinationResolver = (DestinationResolver) this.destinationResolver.getIfUnique();
    if (destinationResolver != null) {
        jmsTemplate.setDestinationResolver(destinationResolver);
    }
    MessageConverter messageConverter = (MessageConverter) this.messageConverter.getIfUnique();
    if (messageConverter != null) {
        jmsTemplate.setMessageConverter(messageConverter);
    }
    //deliveryMode, priority, timeToLive 的开关,要生效,必须配置为true,默认false
    jmsTemplate.setExplicitQosEnabled(true);
    //DeliveryMode.NON_PERSISTENT=1:非持久 ; DeliveryMode.PERSISTENT=2:持久
    
//定义持久化后节点挂掉以后,重启可以继续消费.
    jmsTemplate.setDeliveryMode(DeliveryMode.PERSISTENT);
    //默认不开启事务
    System.out.println("默认是否开启事务:"+jmsTemplate.isSessionTransacted());
    //如果不启用事务,则会导致XA事务失效;
    
//作为生产者如果需要支持事务,则需要配置SessionTransacted为true
  
//jmsTemplate.setSessionTransacted(true);
    
//消息的应答方式,需要手动确认,此时SessionTransacted必须被设置为false,且为Session.CLIENT_ACKNOWLEDGE模式
    
//Session.AUTO_ACKNOWLEDGE  消息自动签收
    
//Session.CLIENT_ACKNOWLEDGE  客户端调用acknowledge方法手动签收
    
//Session.DUPS_OK_ACKNOWLEDGE 不必必须签收,消息可能会重复发送
    jmsTemplate.setSessionAcknowledgeMode(Session.CLIENT_ACKNOWLEDGE);
    return jmsTemplate;
}

/**
 * 配置发布订阅生产者的JmsTemplate
 * 
@return JmsTemplate
 
*/
@Bean(name="jmsTopicTemplate")
public JmsTemplate jmsTopicTemplate() {
    //设置创建连接的工厂
   
//JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory);
    
//优化连接工厂,这里应用缓存池 连接工厂就即可
    JmsTemplate jmsTemplate = new JmsTemplate(cachingConnectionFactory);
    //设置默认消费topic
  
//jmsTemplate.setDefaultDestination(topic());
    
//设置发布订阅消息类型
    jmsTemplate.setPubSubDomain(isPubSubDomain);


    //deliveryMode, priority, timeToLive 的开关,要生效,必须配置为true,默认false
    jmsTemplate.setExplicitQosEnabled(true);
    //DeliveryMode.NON_PERSISTENT=1:非持久 ; DeliveryMode.PERSISTENT=2:持久
    jmsTemplate.setDeliveryMode(DeliveryMode.PERSISTENT);

    //默认不开启事务
    System.out.println("是否开启事务"+jmsTemplate.isSessionTransacted());
    //如果session带有事务,并且事务成功提交,则消息被自动签收。如果事务回滚,则消息会被再次传送。
    
//jmsTemplate.setSessionTransacted(true);

    
//不带事务的session的签收方式,取决于session的配置。
    
//默认消息确认方式为1,即AUTO_ACKNOWLEDGE
    System.out.println("是否消息确认方式"+jmsTemplate.getSessionAcknowledgeMode());

    //消息的应答方式,需要手动确认,此时SessionTransacted必须被设置为false,且为Session.CLIENT_ACKNOWLEDGE模式
    
//Session.AUTO_ACKNOWLEDGE  消息自动签收
    
//Session.CLIENT_ACKNOWLEDGE  客户端调用acknowledge方法手动签收
    
//Session.DUPS_OK_ACKNOWLEDGE 不必必须签收,消息可能会重复发送
    jmsTemplate.setSessionAcknowledgeMode(Session.CLIENT_ACKNOWLEDGE);

    return jmsTemplate;
}

}

posted @ 2019-07-24 11:40 paulwong 阅读(679) | 评论 (0)编辑 收藏

Enterprise Integration Patterns

Why Enterprise Integration Patterns?

Enterprise integration is too complex to be solved with a simple 'cookbook' approach. Instead, patterns can provide guidance by documenting the kind of experience that usually lives only in architects' heads: they are accepted solutions to recurring problems within a given context. Patterns are abstract enough to apply to most integration technologies, but specific enough to provide hands-on guidance to designers and architects. Patterns also provide a vocabulary for developers to efficiently describe their solution.

Patterns are not 'invented'; they are harvested from repeated use in practice. If you have built integration solutions, it is likely that you have used some of these patterns, maybe in slight variations and maybe calling them by a different name. The purpose of this site is not to "invent" new approaches, but to present a coherent collection of relevant and proven patterns, which in total form an integration pattern language.

Despite the 700+ pages, our book covers only a fraction of patterns (and the problems to be solved) in the integration space. The current patterns focus on Messaging, which forms the basis of most other integration patterns. We have started to harvest more patterns but are realizing (once again) how much work documenting these patterns really is. So please stay tuned.

Messaging Patterns

We have documented 65 messaging patterns, organized as follows:

Message Construct.
Message
Command Message
Document Message
Event Message
Request-Reply
Return Address
Correlation Identifier
Message Sequence
Message Expiration
Format Indicator
Message Routing
Pipes-and-Filters
Message Router
Content-based Router
Message Filter
Dynamic Router
Recipient List
Splitter
Aggregator
Resequencer
Composed Msg. Processor
Scatter-Gather
Routing Slip
Process Manager
Message Broker
Message
Transformation
Message Translator
Envelope Wrapper
Content Enricher
Content Filter
Claim Check
Normalizer
Canonical Data Model
Messaging Endpoints
Message Endpoint
Messaging Gateway
Messaging Mapper
Transactional Client
Polling Consumer
Event-driven Consumer
Competing Consumers
Message Dispatcher
Selective Consumer
Durable Subscriber
Idempotent Receiver
Service Activator
Messaging Channels
Message Channel
Point-to-Point Channel
Publish-Subscr. Channel
Datatype Channel
Invalid Message Channel
Dead Letter Channel
Guaranteed Delivery
Channel Adapter
Messaging Bridge
Message Bus
Systems Mgmt.
Control Bus
Detour
Wire Tap
Message History
Message Store
Smart Proxy
Test Message
Channel Purger


https://www.enterpriseintegrationpatterns.com/patterns/messaging/index.html

posted @ 2019-07-18 14:11 paulwong 阅读(119) | 评论 (0)编辑 收藏

SPRING BATCH & SPRING INTEGRATION TUTORIAL

Spring JMS Artemis Example 6 minute read

A detailed step-by-step tutorial on how to connect to Apache ActiveMQ Artemis using Spring JMS and Spring Boot.

Spring JMS Topic Example 5 minute read

A detailed step-by-step tutorial on how to publish/subscribe to a JMS topic using Spring JMS and Spring Boot.

Spring JMS Integration Example12 minute read

A detailed step-by-step tutorial on how to connect to an ActiveMQ JMS broker using Spring Integration and Spring Boot.

Spring JMS Listener Example 7 minute read

A detailed step-by-step tutorial on how a Spring JMS listener works in combination with Spring Boot.

Spring JMS JmsTemplate Example 7 minute read

A detailed step-by-step tutorial on how to use JmsTemplate in combination with Spring JMS and Spring Boot.

Spring JMS Message Converter Example5 minute read

A detailed step-by-step tutorial on how to implement a message converter using Spring JMS and Spring Boot.

Spring Batch Admin Example 11 minute read

A detailed step-by-step tutorial on how to use a Spring Boot admin UI to manage Spring Batch jobs.

Spring Batch Example 11 minute read

A detailed step-by-step tutorial on how to implement a Hello World Spring Batch job using Spring Boot.

posted @ 2019-07-18 13:21 paulwong 阅读(129) | 评论 (0)编辑 收藏

仅列出标题
共95页: First 上一页 4 5 6 7 8 9 10 11 12 下一页 Last