??xml version="1.0" encoding="utf-8" standalone="yes"?>棒球比分直播7m:BlogJava-新手?/title><link>//www.355548.live/beginner</link><description>专注于Java技?/description><language>zh - 棒球比分大小怎么算|վ//www.355548.live/paulwong/archive/2020/06/04/435480.htmlpaulwongpaulwongThu, 04 Jun 2020 02:38:00 GMT//www.355548.live/paulwong/archive/2020/06/04/435480.html//www.355548.live/paulwong/comments/435480.html//www.355548.live/paulwong/archive/2020/06/04/435480.html#Feedback0//www.355548.live/paulwong/comments/commentRss/435480.html//www.355548.live/paulwong/services/trackbacks/435480.html//jartto.wang/tags/git/



paulwong 2020-06-04 10:38 发表评论
]]>
d搞懂 Git-Rebase - 棒球比分大小怎么算|վ//www.355548.live/paulwong/archive/2020/06/04/435479.htmlpaulwongpaulwongThu, 04 Jun 2020 02:37:00 GMT//www.355548.live/paulwong/archive/2020/06/04/435479.html//www.355548.live/paulwong/comments/435479.html//www.355548.live/paulwong/archive/2020/06/04/435479.html#Feedback0//www.355548.live/paulwong/comments/commentRss/435479.html//www.355548.live/paulwong/services/trackbacks/435479.htmlGIT会将功能分支1上的所有COMMIT另存一个文Ӟ回退到分?原始状态,再更新至当前分支1的状态,再把另存文g的COMMIT执行一遍,成了已l合q的新的功能分支1?br />
//jartto.wang/2018/12/11/git-rebase/


paulwong 2020-06-04 10:37 发表评论
]]>
How To Run Java Jar Application with Systemd on Linux - 棒球比分大小怎么算|վ//www.355548.live/paulwong/archive/2020/05/11/435427.htmlpaulwongpaulwongMon, 11 May 2020 08:16:00 GMT//www.355548.live/paulwong/archive/2020/05/11/435427.html//www.355548.live/paulwong/comments/435427.html//www.355548.live/paulwong/archive/2020/05/11/435427.html#Feedback0//www.355548.live/paulwong/comments/commentRss/435427.html//www.355548.live/paulwong/services/trackbacks/435427.htmlhttps://computingforgeeks.com/how-to-run-java-jar-application-with-systemd-on-linux/

systemd自启动javaE序
https://www.cnblogs.com/yoyotl/p/8178363.html
------------------------------------------------------------

[Unit]
Description=TestJava
After=network.target

[Service]
Type=forking
ExecStart=/home/test/startTest.sh
ExecStop=/home/test/stopTest.sh

[Install]
WantedBy=multi-user.target

-------------------------------------------------------------
How to Autorun application at the start up in Linux
https://developer.toradex.com/knowledge-base/how-to-autorun-application-at-the-start-up-in-linux

How to automatically run program on Linux startup
https://www.simplified.guide/linux/automatically-run-program-on-startup


Systemd 入门教程Q实战篇
https://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-part-two.html

Systemd 入门教程Q命令篇

//www.ruanyifeng.com/blog/2016/03/systemd-tutorial-commands.html

paulwong 2020-05-11 16:16 发表评论
]]>
How to disable IPv6 on CentOS / RHEL 7 - 棒球比分大小怎么算|վ//www.355548.live/paulwong/archive/2020/05/06/435410.htmlpaulwongpaulwongWed, 06 May 2020 04:42:00 GMT//www.355548.live/paulwong/archive/2020/05/06/435410.html//www.355548.live/paulwong/comments/435410.html//www.355548.live/paulwong/archive/2020/05/06/435410.html#Feedback0//www.355548.live/paulwong/comments/commentRss/435410.html//www.355548.live/paulwong/services/trackbacks/435410.html https://www.thegeekdiary.com/centos-rhel-7-how-to-disable-ipv6/

https://linuxconfig.org/redhat-8-enable-disable-ipv6




paulwong 2020-05-06 12:42 发表评论
]]>
How To Count Files in Directory on Linux - 棒球比分大小怎么算|վ//www.355548.live/paulwong/archive/2020/05/05/435404.htmlpaulwongpaulwongTue, 05 May 2020 09:01:00 GMT//www.355548.live/paulwong/archive/2020/05/05/435404.html//www.355548.live/paulwong/comments/435404.html//www.355548.live/paulwong/archive/2020/05/05/435404.html#Feedback0//www.355548.live/paulwong/comments/commentRss/435404.html//www.355548.live/paulwong/services/trackbacks/435404.htmlhttps://devconnected.com/how-to-count-files-in-directory-on-linux/



paulwong 2020-05-05 17:01 发表评论
]]>
搭徏React环境Q运行React目 - 棒球比分大小怎么算|վ//www.355548.live/ZouYonghui/archive/2020/04/16/435361.htmlTerry ZouTerry ZouThu, 16 Apr 2020 07:25:00 GMT//www.355548.live/ZouYonghui/archive/2020/04/16/435361.html//www.355548.live/ZouYonghui/comments/435361.html//www.355548.live/ZouYonghui/archive/2020/04/16/435361.html#Feedback0//www.355548.live/ZouYonghui/comments/commentRss/435361.html//www.355548.live/ZouYonghui/services/trackbacks/435361.html2.安装cnpm用cnpm替代npm
    地址Q//npm.taobao.org/
安装cnpm:
npm install -g cnpm --registry=https://registry.npm.taobao.org

3、用yarn替代npm
yarn的安装:
W一U方法:参考官Ҏ?https://yarn.bootcss.com/
W二U方法:cnpm install -g yarn  或?npm install -g yarn
4、搭建React开发环境的W一U方法(?现在推荐Q:
https://reactjs.org/docs/create-a-new-react-app.html
1、必要安装nodejs     注意Q安装nodejsE_版本      教程中的nodejs版本:v8.11.2            教程中的npm版本:v5.6.0
2.安装脚手架工?nbsp;  Q单文glg目生成工具Q?nbsp;  只需要安装一?/div>
npm install -g create-react-app   /  cnpm install -g create-react-app
3.创徏目   Q可能创建多ơ)
扑ֈ目要创建的目录Q?/div>
                create-react-app reactdemo
4.cd  到项目里?span style="white-space:pre">
        cd  reactdemo
                npm start             yarn startq行目
                npm run build         yarn build 生成目
5、搭建React的开发环境的W二U方法(?未来推荐Q:
        https://reactjs.org/docs/create-a-new-react-app.html
        1、必要安装nodejs     注意Q安装nodejsE_版本      教程中的nodejs版本:v8.11.2            教程中的npm版本:v5.6.0
        2.安装脚手架工具ƈ创徏目
            扑ֈ目要创建的目录执行Q?/div>
npx create-react-app reactdemo
4.cd  到项目里?span style="white-space: pre;">
        cd  reactdemo
                npm start  q行目Q调试)
                npm run build 生成目Q发布)
npx介绍Q?/div>
npm v5.2.0引入的一条命令(npxQ,引入q个命o的目的是Z提升开发者用包内提供的命o行工L体验?/div>
详情Q?/div>
        npx create-react-app reactdemoq条命o会时安?create-react-app 包,命o完成后create-react-app 会删掉,不会出现?global 中。下ơ再执行Q还是会重新临时安装?/div>
npx 会帮你执行依赖包里的二进制文件?/div>
        再比?npx http-server 可以一句话帮你开启一个静态服务器


Terry Zou 2020-04-16 15:25 发表评论
]]>Spring中的ApplicationListener的用详解案例(观察者模? - 棒球比分大小怎么算|վ//www.355548.live/ZouYonghui/archive/2020/04/09/435329.htmlTerry ZouTerry ZouThu, 09 Apr 2020 06:47:00 GMT//www.355548.live/ZouYonghui/archive/2020/04/09/435329.html//www.355548.live/ZouYonghui/comments/435329.html//www.355548.live/ZouYonghui/archive/2020/04/09/435329.html#Feedback0//www.355548.live/ZouYonghui/comments/commentRss/435329.html//www.355548.live/ZouYonghui/services/trackbacks/435329.html1、ApplicationContext
Spring的核心,Context我们通常解释Z下文环境。ApplicationContext则是应用的容器?Spring把BeanQobjectQ放在容器中Q需要用通过getҎ取出来。在ApplicationContext接口的众多实现类中,?个是我们l常用到的(见表1-1Q,q且使用q?个实现类也基本能满我们Java EE应用开发中的绝大部分需求?/div>
?-1 ApplicationContext接口的常用实现类介绍
ClassPathXmlApplicationContext
从类路径ClassPath中寻找指定的XML配置文gQ找到ƈ装蝲完成ApplicationContext的实例化工作。例如: //装蝲单个配置文g实例化ApplicationContext容器
ApplicationContext cxt = new ClassPathXmlApplicationContext("applicationContext.xml");
//装蝲多个配置文g实例化ApplicationContext容器
String[] configs = {"bean1.xml","bean2.xml","bean3.xml"};
ApplicationContext cxt = new ClassPathXmlApplicationContext(configs);
FileSystemXmlApplicationContext
从指定的文gpȝ路径中寻找指定的XML配置文gQ找到ƈ装蝲完成ApplicationContext的实例化工作。例如://装蝲单个配置文g实例化ApplicationContext容器
ApplicationContext cxt = new FileSystemXMLApplicationContext("beans.xml");
//装蝲多个配置文g实例化ApplicationContext容器
String[] configs = {"c:/beans1.xml","c:/beans2.xml"};
ApplicationContext cxt = new FileSystemXmlApplicationContext(configs);
XmlWebApplicationContext
从Web应用中寻找指定的XML配置文gQ找到ƈ装蝲完成ApplicationContext的实例化工作。这是ؓWeb工程量n定制的,使用WebApplicationContextUtilscȝgetRequiredWebApplicationContextҎ可在JSP与Servlet中取得IoC容器的引?/div>
2、ApplicationEvent
是个抽象c,里面只有一个构造函数和一个长整型的timestamp。其源码如下

public abstract class ApplicationEvent extends EventObject {
 
    /** use serialVersionUID from Spring 1.2 for interoperability */
    private static final long serialVersionUID = 7099057708183571937L;
 
    /** System time when the event happened */
    private final long timestamp;
 
    /**
     * Create a new ApplicationEvent.
     * 
@param source the object on which the event initially occurred (never {@code null})
     
*/
    public ApplicationEvent(Object source) {
        super(source);
        this.timestamp = System.currentTimeMillis();
    }
 
    /**
     * Return the system time in milliseconds when the event happened.
     
*/
    public final long getTimestamp() {
        return this.timestamp;
    }
}

3、ApplicationListener

是一个接口,里面只有一个onApplicationEventҎ。如果在上下文中部v一个实CApplicationListener接口的bean,那么每当在一个ApplicationEvent发布?ApplicationContextӞ调用ApplicationContext.publishEvent()ҎQ这个bean得到通知。类gOberver设计模式?/span>
其源码如下:

public interface ApplicationListener<E extends ApplicationEvent> extends EventListener {
    /**
     * Handle an application event.
     * 
@param event the event to respond to
     
*/
    void onApplicationEvent(E event);
 
}
下面举个例子
自定义事件NotifyEvent:
import org.springframework.context.ApplicationEvent;

public class NotifyEvent  extends ApplicationEvent  {
    private String email;
    private String content;
    public NotifyEvent(Object source){
        super(source);
    }

    public NotifyEvent(Object source,String email,String content){
        super(source);
        this.email = email;
        this.content = content;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }
}

定义监听器NotifyListener:
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Configuration;

@Configuration
public class NotifyListener implements ApplicationListener<NotifyEvent>{
    @Override
    public void onApplicationEvent(NotifyEvent event) {
        System.out.println("邮g地址Q? + event.getEmail());
        System.out.println("邮g内容Q? + event.getContent());
    }
}

单元试cListenerTestQ?/span>
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.context.WebApplicationContext;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = ServerLauncher.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class ListenerTest {
    @Autowired
    private WebApplicationContext webApplicationContext;

    @Test
    public void testListener(){
        NotifyEvent event = new NotifyEvent("object","abc@qq.com","This is the content");
        webApplicationContext.publishEvent(event);
    }
}


Terry Zou 2020-04-09 14:47 发表评论
]]>JENKINS TOURIAL - 棒球比分大小怎么算|վ//www.355548.live/paulwong/archive/2020/04/07/435324.htmlpaulwongpaulwongTue, 07 Apr 2020 02:29:00 GMT//www.355548.live/paulwong/archive/2020/04/07/435324.html//www.355548.live/paulwong/comments/435324.html//www.355548.live/paulwong/archive/2020/04/07/435324.html#Feedback0//www.355548.live/paulwong/comments/commentRss/435324.html//www.355548.live/paulwong/services/trackbacks/435324.htmlhttps://huongdanjava.com/jenkins-2



paulwong 2020-04-07 10:29 发表评论
]]>
Deploy artifacts into Maven Repository in Jenkins - 棒球比分大小怎么算|վ//www.355548.live/paulwong/archive/2020/04/06/435321.htmlpaulwongpaulwongMon, 06 Apr 2020 06:13:00 GMT//www.355548.live/paulwong/archive/2020/04/06/435321.html//www.355548.live/paulwong/comments/435321.html//www.355548.live/paulwong/archive/2020/04/06/435321.html#Feedback0//www.355548.live/paulwong/comments/commentRss/435321.html//www.355548.live/paulwong/services/trackbacks/435321.htmlhttps://huongdanjava.com/deploy-artifacts-into-maven-repository-in-jenkins.html



paulwong 2020-04-06 14:13 发表评论
]]>
MAVENU服-Nexus Repository Manager - 棒球比分大小怎么算|վ//www.355548.live/paulwong/archive/2020/04/06/435320.htmlpaulwongpaulwongMon, 06 Apr 2020 06:08:00 GMT//www.355548.live/paulwong/archive/2020/04/06/435320.html//www.355548.live/paulwong/comments/435320.html//www.355548.live/paulwong/archive/2020/04/06/435320.html#Feedback0//www.355548.live/paulwong/comments/commentRss/435320.html//www.355548.live/paulwong/services/trackbacks/435320.html

Nexus Repository Manager is a tool that allows us to store and use libraries we need in projects such as Maven project…

Nexus Repository ManagerIn this tutorial, I summarize the tutorials of Huong Dan Java on the Nexus Repository Manager for your reference.


Installation

In this tutorial, I will guide you how to install Nexus Repository Manager.


Configuration

In order to create a new Maven Repository in the Nexus Repository Manager, you can refer to this tutorial.

We need to define a Role to define User rights in the Nexus Repository Manager.

To be able to do anything in the Nexus Repository Manager, you need to create and use the User.


Manipulation

Nexus Repository Manager supports us UI to upload any artifact to the Repository.

In addition to the UI, we can also use the RESTful API to upload an artifact.



paulwong 2020-04-06 14:08 发表评论
]]>
List sessions / active connections on MariaDB server - 棒球比分大小怎么算|վ//www.355548.live/paulwong/archive/2020/04/02/435313.htmlpaulwongpaulwongThu, 02 Apr 2020 07:38:00 GMT//www.355548.live/paulwong/archive/2020/04/02/435313.html//www.355548.live/paulwong/comments/435313.html//www.355548.live/paulwong/archive/2020/04/02/435313.html#Feedback0//www.355548.live/paulwong/comments/commentRss/435313.html//www.355548.live/paulwong/services/trackbacks/435313.htmlUsing a command

Option 1

show status where variable_name = 'threads_connected'; 

Columns

  • Variable_name - Name of the variable shown
  • Value - Number of active connections

Rows

  • One row: Only one row is displayed

Sample results

Option 2

show processlist; 

Columns

  • Id - The connection identifier
  • User - The MariaDB user who issued the statement
  • Host - Host name and client port of the client issuing the statement
  • db - The default database (schema), if one is selected, otherwise NULL
  • Command - The type of command the thread is executing
  • Time - The time in seconds that the thread has been in its current state
  • State - An action, event, or state that indicates what the thread is doing
  • Info - The statement the thread is executing, or NULL if it is not executing any statement
  • Progress - The total progress of the process (0-100%)

Rows

  • One row: represents one active connection
  • Scope of rows: total of active connections

Sample results

Using a query

Option 3

select id, user, host, db, command, time, state, 
info, progress from information_schema.processlist;

Columns

  • Id - The connection identifier
  • User - The MariaDB user who issued the statement
  • Host - Host name and client port of the client issuing the statement
  • db - The default database (schema), if one is selected, otherwise NULL
  • Command - The type of command the thread is executing
  • Time - The time in seconds that the thread has been in its current state
  • State - An action, event, or state that indicates what the thread is doing
  • Info - The statement the thread is executing, or NULL if it is not executing any statement
  • Progress - The total progress of the process (0-100%)
  • memory_used - Amount of memory used by the active connection

Rows

  • One row: represents one active connection
  • Scope of rows: total of active connections

Sample results

Using the GUI

Option 4

Click on the Client Connections option of the Management tab (left navigation pane)

This action will show the Client Connections screen containing the current active connections



paulwong 2020-04-02 15:38 发表评论
]]>
Finding slow queries in MongoDB - 棒球比分大小怎么算|վ//www.355548.live/paulwong/archive/2020/03/27/435309.htmlpaulwongpaulwongFri, 27 Mar 2020 15:35:00 GMT//www.355548.live/paulwong/archive/2020/03/27/435309.html//www.355548.live/paulwong/comments/435309.html//www.355548.live/paulwong/archive/2020/03/27/435309.html#Feedback0//www.355548.live/paulwong/comments/commentRss/435309.html//www.355548.live/paulwong/services/trackbacks/435309.htmlDatabase Profiling

MongoDB Profiler is a db profiling system that can help identify inefficient

or slow queries and operations.

Levels of profiles available are:

Level

Setting

0

Off. & No profiling

1

On & only includes slow operations

2

On & Includes all operations


We can enable it by setting the Profile level value using the following
command in mongo shell :

"db.setProfilingLevel(1)"

By default, mongod records slow queries to its log, as defined by slowOpThresholdMs.

NOTE

Enabling database profiler puts negative impact on MongoDB’s performance.

It’s better to enable it for specific intervals & minimal on Production Servers.

We can enable profiling on a mongod basis but This setting will not propagate
across a replica set and sharded cluster.

We can view the output in the system.profile collection in mongo shell using show profile command, or using following:

db.system.profile.find( { millis : { $gt : 200 } } )

Command returns operations that took longer than 200 ms. Similarly we
can change the values as per our need.

Enabling profile for an entire mongod instance.

For the purpose of development in testing, we can enable database profiling/settings for an 
entire mongod instance. The profiling level will be applied to all databases.

 

NOTE:

We can't enable the profiling settings on a mongos instance. To enable the profiling in

shard clusters, we have to enable/start profiling for each mongod instance in cluster.

 

Query for the recent 10 entries

db.system.profile.find().limit(10).sort( { ts : 1 } ).pretty()

 

Collection with the slowest queries(No. Of queries)

db.system.profile.group({key: {ns: true}, initial: {count: 0}, reduce: function(obj,prev){ prev.count++;}})

 

Collection with the slowest queries(No. Of millis spent)

db.system.profile.group({key: {ns: true}, initial: {millis: 0}, reduce: function(obj, prev){ prev.millis += obj.millis;}})

 

Most recent slow query

db.system.profile.find().sort({$natural: -1}).limit(1)

 

Single slowest query(Right now)

db.system.profile.find().sort({millis: -1}).limit(1)



paulwong 2020-03-27 23:35 发表评论
]]>
ZLINUX的分布式文gpȝGlusterFS + NFS-Ganesha - 棒球比分大小怎么算|վ//www.355548.live/paulwong/archive/2020/03/22/435293.htmlpaulwongpaulwongSun, 22 Mar 2020 03:46:00 GMT//www.355548.live/paulwong/archive/2020/03/22/435293.html//www.355548.live/paulwong/comments/435293.html//www.355548.live/paulwong/archive/2020/03/22/435293.html#Feedback0//www.355548.live/paulwong/comments/commentRss/435293.html//www.355548.live/paulwong/services/trackbacks/435293.html
GlusterFS是分布文件存储系l, 也即一个文件有三个备䆾Q每个备份可以放C同的节点(IP)上,q样某个节点CRASH后,会从其他节点取文件?br />
NFS-Ganesha则是用户层面非KERNAL层面的实CNFS SERVER的功能,但双加了扩展Q对外提供基于NFS协议的文件存取服务?br />
资源Q?br />GlusterFS and NFS-Ganesha integration
https://staged-gluster-docs.readthedocs.io/en/release3.7.0beta1/Features/glusterfs_nfs-ganesha_integration/

Exporting and Unexporting Volumes through nfs-ganesha
https://access.redhat.com/documentation/en-US/Red_Hat_Storage/2.1/html/Administration_Guide/Starting_and_Stopping_nfs-ganesha.html

https://www.snia.org/sites/default/files/Poornima_NFS_GaneshaForClusteredNAS.pdf







paulwong 2020-03-22 11:46 发表评论
]]>
开机nfs自动挂蝲 - 棒球比分大小怎么算|վ//www.355548.live/paulwong/archive/2020/03/21/435290.htmlpaulwongpaulwongSat, 21 Mar 2020 11:44:00 GMT//www.355548.live/paulwong/archive/2020/03/21/435290.html//www.355548.live/paulwong/comments/435290.html//www.355548.live/paulwong/archive/2020/03/21/435290.html#Feedback0//www.355548.live/paulwong/comments/commentRss/435290.html//www.355548.live/paulwong/services/trackbacks/435290.htmlQ.echo "mount -t nfs -o nolock ${IP}:${remote_dir} ${local_dir}" >>  /etc/rc.local

Q.echo "${IP}:/home/logs /home/logs nfs defaults 0 0" >> /etc/fstab

棒球比分直播7m:关于/etc/rc.local


rc.local也是我经怋用的一个脚本。该脚本是在pȝ初始化别脚本运行之后再执行的,因此可以安全地在里面d你想在系l启动之后执行的脚本。常见的情况是你可以再里面添加nfs挂蝲/mount脚本。此外,你也可以在里面添加一些调试用的脚本命令。例如,我就到q这U情况:samba服务L无法正常q行Q而检查发玎ͼsamba是在pȝ启动q程中就该启动执行的Q也是_samba守护E序配置保证了这U功能本应该正确执行。碰到这U类似情况,一般我也懒得花大量旉LZ么,我只需要简单的?etc/rc.local脚本里加上这么一行:

/etc/init.d/samba start

q样成功的解决了samba服务异常的问题?img src ="//www.355548.live/paulwong/aggbug/435290.html" width = "1" height = "1" />

paulwong 2020-03-21 19:44 发表评论
]]>利用 Chef ?Red Hat Enterprise Linux 上自动化部v Mariadb Galera Cluster - 棒球比分大小怎么算|վ//www.355548.live/paulwong/archive/2020/03/21/435289.htmlpaulwongpaulwongSat, 21 Mar 2020 02:55:00 GMT//www.355548.live/paulwong/archive/2020/03/21/435289.html//www.355548.live/paulwong/comments/435289.html//www.355548.live/paulwong/archive/2020/03/21/435289.html#Feedback0//www.355548.live/paulwong/comments/commentRss/435289.html//www.355548.live/paulwong/services/trackbacks/435289.htmlhttps://www.ibm.com/developerworks/cn/linux/1611_chensz_mgc/index.html



paulwong 2020-03-21 10:55 发表评论
]]>
在SPRING BOOT中用多JMS CONNECTION - 棒球比分大小怎么算|վ//www.355548.live/paulwong/archive/2020/03/19/435278.htmlpaulwongpaulwongThu, 19 Mar 2020 01:45:00 GMT//www.355548.live/paulwong/archive/2020/03/19/435278.html//www.355548.live/paulwong/comments/435278.html//www.355548.live/paulwong/archive/2020/03/19/435278.html#Feedback0//www.355548.live/paulwong/comments/commentRss/435278.html//www.355548.live/paulwong/services/trackbacks/435278.html
ActiveMQConnectionFactoryFactory.java
import java.lang.reflect.InvocationTargetException;
import java.util.Collections;
import java.util.List;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQConnectionFactoryCustomizer;
import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQProperties;
import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQProperties.Packages;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;


/**
 * Factory to create a {
@link ActiveMQConnectionFactory} instance from properties defined
 * in {
@link SecondaryActiveMQProperties}.
 *
 * 
@author Phillip Webb
 * 
@author Venil Noronha
 
*/
class ActiveMQConnectionFactoryFactory {

    private static final String DEFAULT_EMBEDDED_BROKER_URL = "vm://localhost?broker.persistent=false";

    private static final String DEFAULT_NETWORK_BROKER_URL = "tcp://localhost:61616";

    private final ActiveMQProperties properties;

    private final List<ActiveMQConnectionFactoryCustomizer> factoryCustomizers;

    ActiveMQConnectionFactoryFactory(ActiveMQProperties properties,
            List<ActiveMQConnectionFactoryCustomizer> factoryCustomizers) {
        Assert.notNull(properties, "Properties must not be null");
        this.properties = properties;
        this.factoryCustomizers = (factoryCustomizers != null) ? factoryCustomizers : Collections.emptyList();
    }

    public <T extends ActiveMQConnectionFactory> T createConnectionFactory(Class<T> factoryClass) {
        try {
            return doCreateConnectionFactory(factoryClass);
        }
        catch (Exception ex) {
            throw new IllegalStateException("Unable to create " + "ActiveMQConnectionFactory", ex);
        }
    }

    private <T extends ActiveMQConnectionFactory> T doCreateConnectionFactory(Class<T> factoryClass) throws Exception {
        T factory = createConnectionFactoryInstance(factoryClass);
        if (this.properties.getCloseTimeout() != null) {
            factory.setCloseTimeout((intthis.properties.getCloseTimeout().toMillis());
        }
        factory.setNonBlockingRedelivery(this.properties.isNonBlockingRedelivery());
        if (this.properties.getSendTimeout() != null) {
            factory.setSendTimeout((intthis.properties.getSendTimeout().toMillis());
        }
        Packages packages = this.properties.getPackages();
        if (packages.getTrustAll() != null) {
            factory.setTrustAllPackages(packages.getTrustAll());
        }
        if (!packages.getTrusted().isEmpty()) {
            factory.setTrustedPackages(packages.getTrusted());
        }
        customize(factory);
        return factory;
    }

    private <T extends ActiveMQConnectionFactory> T createConnectionFactoryInstance(Class<T> factoryClass)
            throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
        String brokerUrl = determineBrokerUrl();
        String user = this.properties.getUser();
        String password = this.properties.getPassword();
        if (StringUtils.hasLength(user) && StringUtils.hasLength(password)) {
            return factoryClass.getConstructor(String.class, String.class, String.class).newInstance(user, password,
                    brokerUrl);
        }
        return factoryClass.getConstructor(String.class).newInstance(brokerUrl);
    }

    private void customize(ActiveMQConnectionFactory connectionFactory) {
        for (ActiveMQConnectionFactoryCustomizer factoryCustomizer : this.factoryCustomizers) {
            factoryCustomizer.customize(connectionFactory);
        }
    }

    String determineBrokerUrl() {
        if (this.properties.getBrokerUrl() != null) {
            return this.properties.getBrokerUrl();
        }
        if (this.properties.isInMemory()) {
            return DEFAULT_EMBEDDED_BROKER_URL;
        }
        return DEFAULT_NETWORK_BROKER_URL;
    }
}

TwinJmsConnectionFactoryConfiguration.java
import java.util.stream.Collectors;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.messaginghub.pooled.jms.JmsPoolConnectionFactory;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.jms.JmsPoolConnectionFactoryFactory;
import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQConnectionFactoryCustomizer;
import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;


@Configuration
@Profile({"local"})
public class TwinJmsConnectionFactoryConfiguration {

    @Bean
    @ConfigurationProperties(prefix = "spring.activemq.primary")
    public ActiveMQProperties primaryActiveMQProperties() {
        return new ActiveMQProperties();
    }
    
    @Bean(destroyMethod = "stop")
    @Primary
    @ConditionalOnProperty(prefix = "spring.activemq.pool", name = "enabled", havingValue = "true")
    public JmsPoolConnectionFactory connectionFactory(ActiveMQProperties primaryActiveMQProperties,
            ObjectProvider<ActiveMQConnectionFactoryCustomizer> factoryCustomizers) {
        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactoryFactory(primaryActiveMQProperties,
                factoryCustomizers.orderedStream().collect(Collectors.toList()))
                .createConnectionFactory(ActiveMQConnectionFactory.class);
        return new JmsPoolConnectionFactoryFactory(primaryActiveMQProperties.getPool())
                .createPooledConnectionFactory(connectionFactory);
    }
    
    ////////////////////////////////////////////////////////////////////////////////
    @Bean
    @ConfigurationProperties(prefix = "spring.activemq.sescond")
    public ActiveMQProperties sescondActiveMQProperties() {
        return new ActiveMQProperties();
    }
    
    @Bean(destroyMethod = "stop")
    @ConditionalOnProperty(prefix = "spring.activemq.pool", name = "enabled", havingValue = "true")
    public JmsPoolConnectionFactory sescondPooledJmsConnectionFactory(ActiveMQProperties sescondActiveMQProperties,
            ObjectProvider<ActiveMQConnectionFactoryCustomizer> factoryCustomizers) {
        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactoryFactory(sescondActiveMQProperties,
                factoryCustomizers.orderedStream().collect(Collectors.toList()))
                .createConnectionFactory(ActiveMQConnectionFactory.class);
        return new JmsPoolConnectionFactoryFactory(sescondActiveMQProperties.getPool())
                .createPooledConnectionFactory(connectionFactory);
    }
    
}




paulwong 2020-03-19 09:45 发表评论
]]>
Which is better: PooledConnectionFactory or CachingConnectionFactory? - 棒球比分大小怎么算|վ//www.355548.live/paulwong/archive/2020/03/19/435277.htmlpaulwongpaulwongThu, 19 Mar 2020 01:37:00 GMT//www.355548.live/paulwong/archive/2020/03/19/435277.html//www.355548.live/paulwong/comments/435277.html//www.355548.live/paulwong/archive/2020/03/19/435277.html#Feedback0//www.355548.live/paulwong/comments/commentRss/435277.html//www.355548.live/paulwong/services/trackbacks/435277.htmlFrom here:

The difference between the PooledConnectionFactory and the CachingConnectionFactory is a difference in implementation. Below are some of the characteristics that differ between them:

  • Although both the PooledConnectionFactory and the CachingConnectionFactory state that they each pool connections, sessions and producers, the PooledConnectionFactory does not actually create a cache of multiple producers. It simply uses a singleton pattern to hand out a single cached producer when one is requested. Whereas the CachingConnectionFactory actually creates a cache containing multiple producers and hands out one producer from the cache when one is requested.

  • The PooledConnectionFactory is built on top of the Apache Commons Pool project for pooling JMS sessions. This allows some additional control over the pool because there are features in Commons Pool that are not being used by the PooledConnectionFactory. These additional features include growing the pool size instead of blocking, throwing an exception when the pool is exhausted, etc. You can utilize these features by creating your own Commons Pool GenericObjectPool using your own customized settings and then handing that object to the PooledConnectionFactory via the setPoolFactory method. See the following for additional info: //commons.apache.org/pool/api-1.4/org/apache/commons/pool/impl/GenericObjectPoolFactory.html

  • The CachingConnectionFactory has the ability to also cache consumers. Just need to take care when using this feature so that you know the consumers are cached according to the rules noted in the blog post.

  • But most importantly, the CachingConnectionFactory will work with any JMS compliant MOM. It only requires a JMS connection factory. This is important if you are using more than one MOM vendor which is very common in enterprise organizations (this is mainly due to legacy and existing projects). The important point is that the CachingConnectionFactory works very well with many different MOM implementations, not only ActiveMQ.

From here:

  • If you have clustered ActiveMQs, and use failover transport it has been reported that CachingConnectionFactory is not a right choice.

  • The problem I’m having is that if one box goes down, we should start sending messages on the other, but it seems to still be using the old connection (every send times out). If I restart the program, it’ll connect again and everything works. Source: Autoreconnect problem with ActiveMQ and CachingConnectionFactory

  • The problem is that cached connections to the failed ActiveMQ was still in use and that created the problem for the user. Now, the choice for this scenario is PooledConnectionFactory.

  • If you’re using ActiveMQ today, and chances are that you may switch to some other broker (JBoss MQ, WebSphere MQ) in future, do not use PooledConnectionFactory, as it tightly couples your code to ActiveMQ.



paulwong 2020-03-19 09:37 发表评论
]]>
Spring Boot Data Mongodb Starter自动配置那些?/title><link>//www.355548.live/paulwong/archive/2020/03/17/435271.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Tue, 17 Mar 2020 01:39:00 GMT</pubDate><guid>//www.355548.live/paulwong/archive/2020/03/17/435271.html</guid><wfw:comment>//www.355548.live/paulwong/comments/435271.html</wfw:comment><comments>//www.355548.live/paulwong/archive/2020/03/17/435271.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>//www.355548.live/paulwong/comments/commentRss/435271.html</wfw:commentRss><trackback:ping>//www.355548.live/paulwong/services/trackbacks/435271.html</trackback:ping><description><![CDATA[<div style="font-size: medium;"><div class="dntg"><p>正好做MongodbM复制试使用Spring Boot Data Mongodb Starter插g链接讉KMongodb数据库集?/p><p>遇到的坑Q?/p><ul class="dntg"><li class="dntg">spring.data.mongodb.host和spring.data.mongodb.port形式不适合集群配置Q会报host无法识别异常</li><li class="dntg">spring.data.mongodb.uri中经常抛出authentication failed异常</li></ul><p><br /></p><p>解决办法Q?/p><ol><li class="dntg"> 对于W一个坑Q请使用spring.data.mongodb.uri?span style="background-color: yellow;">如果使用了uriQ则其余的host/username/password/db/auth-dbq些全部无效?/span></li><li class="dntg"> 对于W二个坑Q请在spring.data.mongodb.uri中指定replicaSet和authsourceQ另外记得把所有集节Ҏ务器地址都列全?br /><span style="background-color: yellow;">如果auth-db和db是同一个,则无需加authsourceQ如果不同,则加authsource=admin</span></li></ol><p><br /></p><p>我没有把authsource指定Q所以一直报authentication failed异常。然后只好一点点d掘问题点Q最后查到在com.mongodb.ConnectionStringcM的createCredentials?br /><br /></p><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />//www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF; ">private</span> MongoCredential createCredentials(<span style="color: #0000FF; ">final</span> Map<String, List<String>> optionsMap, <span style="color: #0000FF; ">final</span> String userName,<br />                                              <span style="color: #0000FF; ">final</span> <span style="color: #0000FF; ">char</span>[] password) {<br />        AuthenticationMechanism mechanism = <span style="color: #0000FF; ">null</span>;<br />        String authSource = (database == <span style="color: #0000FF; ">null</span>) ? "admin" : database;<br />        String gssapiServiceName = <span style="color: #0000FF; ">null</span>;<br />        String authMechanismProperties = <span style="color: #0000FF; ">null</span>;<br /><br />        <span style="color: #0000FF; ">for</span> (<span style="color: #0000FF; ">final</span> String key : AUTH_KEYS) {<br />            String value = getLastValue(optionsMap, key);<br /><br />            <span style="color: #0000FF; ">if</span> (value == <span style="color: #0000FF; ">null</span>) {<br />                <span style="color: #0000FF; ">continue</span>;<br />            }<br /><br />            <span style="color: #0000FF; ">if</span> (key.equals("authmechanism")) {<br />                mechanism = AuthenticationMechanism.fromMechanismName(value);<br />            } <span style="color: #0000FF; ">else</span> <span style="color: #0000FF; ">if</span> (key.equals("authsource")) {<br />                authSource = value;<br />            } <span style="color: #0000FF; ">else</span> <span style="color: #0000FF; ">if</span> (key.equals("gssapiservicename")) {<br />                gssapiServiceName = value;<br />            } <span style="color: #0000FF; ">else</span> <span style="color: #0000FF; ">if</span> (key.equals("authmechanismproperties")) {<br />                authMechanismProperties = value;<br />            }<br />        }<br /><br /><br />        MongoCredential credential = <span style="color: #0000FF; ">null</span>;<br />        <span style="color: #0000FF; ">if</span> (mechanism != <span style="color: #0000FF; ">null</span>) {<br />            <span style="color: #0000FF; ">switch</span> (mechanism) {<br />                <span style="color: #0000FF; ">case</span> GSSAPI:<br />                    credential = MongoCredential.createGSSAPICredential(userName);<br />                    <span style="color: #0000FF; ">if</span> (gssapiServiceName != <span style="color: #0000FF; ">null</span>) {<br />                        credential = credential.withMechanismProperty("SERVICE_NAME", gssapiServiceName);<br />                    }<br />                    <span style="color: #0000FF; ">break</span>;<br />                <span style="color: #0000FF; ">case</span> PLAIN:<br />                    credential = MongoCredential.createPlainCredential(userName, authSource, password);<br />                    <span style="color: #0000FF; ">break</span>;<br />                <span style="color: #0000FF; ">case</span> MONGODB_CR:<br />                    credential = MongoCredential.createMongoCRCredential(userName, authSource, password);<br />                    <span style="color: #0000FF; ">break</span>;<br />                <span style="color: #0000FF; ">case</span> MONGODB_X509:<br />                    credential = MongoCredential.createMongoX509Credential(userName);<br />                    <span style="color: #0000FF; ">break</span>;<br />                <span style="color: #0000FF; ">case</span> SCRAM_SHA_1:<br />                    credential = MongoCredential.createScramSha1Credential(userName, authSource, password);<br />                    <span style="color: #0000FF; ">break</span>;<br />                <span style="color: #0000FF; ">default</span>:<br />                    <span style="color: #0000FF; ">throw</span> <span style="color: #0000FF; ">new</span> UnsupportedOperationException(format("The connection string contains an invalid authentication mechanism'. "<br />                                                                           + "'%s' is not a supported authentication mechanism",<br />                            mechanism));<br />            }<br />        } <span style="color: #0000FF; ">else</span> <span style="color: #0000FF; ">if</span> (userName != <span style="color: #0000FF; ">null</span>) {<br />            credential = MongoCredential.createCredential(userName, authSource, password);<br />        }<br /><br />        <span style="color: #0000FF; ">if</span> (credential != <span style="color: #0000FF; ">null</span> && authMechanismProperties != <span style="color: #0000FF; ">null</span>) {<br />            <span style="color: #0000FF; ">for</span> (String part : authMechanismProperties.split(",")) {<br />                String[] mechanismPropertyKeyValue = part.split(":");<br />                <span style="color: #0000FF; ">if</span> (mechanismPropertyKeyValue.length != 2) {<br />                    <span style="color: #0000FF; ">throw</span> <span style="color: #0000FF; ">new</span> IllegalArgumentException(format("The connection string contains invalid authentication properties. "<br />                            + "'%s' is not a key value pair", part));<br />                }<br />                String key = mechanismPropertyKeyValue[0].trim().toLowerCase();<br />                String value = mechanismPropertyKeyValue[1].trim();<br />                <span style="color: #0000FF; ">if</span> (key.equals("canonicalize_host_name")) {<br />                    credential = credential.withMechanismProperty(key, Boolean.valueOf(value));<br />                } <span style="color: #0000FF; ">else</span> {<br />                    credential = credential.withMechanismProperty(key, value);<br />                }<br />            }<br />        }<br />        <span style="color: #0000FF; ">return</span> credential;<br />    }</div><p><br /></p><p>authSource默认会指向我们目标数据的数据库。然而在w䆾验证机制中我们通常需要指向admin。(非常x_口Q代码作者在q里脑袋被men挤了么)。所以需要强制指定authSource中指定。具体指定方式如下:</p><p> </p><p> </p><p> </p><p> </p><pre bash"=""><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />//www.CodeHighlighter.com/<br /><br />-->mongodb://{用户名}:{密码}@{host1}:27017,{host2}:27017,{host3}:27017/{目标数据库}?replicaSet={复制集名U}&write=1&readPreference=primary&authsource={授权数据库}</div></pre></div></div><img src ="//www.355548.live/paulwong/aggbug/435271.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="//www.355548.live/paulwong/" target="_blank">paulwong</a> 2020-03-17 09:39 <a href="//www.355548.live/paulwong/archive/2020/03/17/435271.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SPRING BATCH中STEP如果没加TRANSACTION MANAGER - 棒球比分大小怎么算|վ//www.355548.live/paulwong/archive/2020/03/16/435267.htmlpaulwongpaulwongMon, 16 Mar 2020 01:43:00 GMT//www.355548.live/paulwong/archive/2020/03/16/435267.html//www.355548.live/paulwong/comments/435267.html//www.355548.live/paulwong/archive/2020/03/16/435267.html#Feedback0//www.355548.live/paulwong/comments/commentRss/435267.html//www.355548.live/paulwong/services/trackbacks/435267.html
+------------+--------------+-------------+-----------------+------------------+--------------------+----------------+-----------+-------------------------
 | READ_COUNT | FILTER_COUNT | WRITE_COUNT | READ_SKIP_COUNT | WRITE_SKIP_COUNT | PROCESS_SKIP_COUNT | ROLLBACK_COUNT | EXIT_CODE | EXIT_MESSAGE
-+------------+--------------+-------------+-----------------+------------------+--------------------+----------------+-----------+-------------------------
 |          1 |            0 |           1 |               0 |                0 |                  0 |              0 | COMPLETED |
 |      30006 |            0 |       29947 |               0 |               59 |                  0 |             61 | COMPLETED | Waited for 101 results.

如上面的L?0006Q但COMMIT的L?9947Q有59个被跌了?br />
因此需在STEP上加TRANSACTION MANAGER.

https://stackoverflow.com/questions/42803941/spring-batch-incorrect-write-skip-count-issue



paulwong 2020-03-16 09:43 发表评论
]]>
mySQL Error 1040: Too Many Connection - 棒球比分大小怎么算|վ//www.355548.live/paulwong/archive/2020/03/10/435247.htmlpaulwongpaulwongTue, 10 Mar 2020 12:20:00 GMT//www.355548.live/paulwong/archive/2020/03/10/435247.html//www.355548.live/paulwong/comments/435247.html//www.355548.live/paulwong/archive/2020/03/10/435247.html#Feedback0//www.355548.live/paulwong/comments/commentRss/435247.html//www.355548.live/paulwong/services/trackbacks/435247.html

To see how many connections are configured for your DB to use:

select @@max_connections;

To change it:

set global max_connections = 200;

To see how many are connected at the current time:

show processlist;
vi /etc/my.cnf

[mysqld]
max_connections = 500


paulwong 2020-03-10 20:20 发表评论
]]>
5 ways to customize Spring MVC JSON/XML output - 棒球比分大小怎么算|վ//www.355548.live/paulwong/archive/2020/03/08/435236.htmlpaulwongpaulwongSun, 08 Mar 2020 07:55:00 GMT//www.355548.live/paulwong/archive/2020/03/08/435236.html//www.355548.live/paulwong/comments/435236.html//www.355548.live/paulwong/archive/2020/03/08/435236.html#Feedback0//www.355548.live/paulwong/comments/commentRss/435236.html//www.355548.live/paulwong/services/trackbacks/435236.htmlhttps://mostafa-asg.github.io/post/customize-json-xml-spring-mvc-output/



]]>
{ganrao}