Thursday, 20 November 2014

Postgres turn on full debugging

1> Find your postgres data folder from pg_ENV.BAT
you should find something like PGDATA=D:\PostgreSQLData

2> from PGDATA\postgresql.conf file, change

log_directory = 'pg_log'        
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
log_statement = 'all'

There are more switch like log_duration etc.


Wednesday, 12 November 2014

ActiveMQBrowser forward reply message to a designated queue

Simply , forward your message to new queue via JMSReplyTo.



You can see the response in the new queue:

Tuesday, 11 November 2014

Email header

一般的郵件傳輸的過程至少經過4台電腦,怎麼說呢,當使用者發送郵件,會在使用者自己的電腦上產出訊息,然後訊息會先送到你指定寄件用的Mail Server(可能是你ISP用的或公司的),此時使用者的電腦已完成它的發送工作,但是Mail Server還沒完成他的工作,他會幫你找到收件者的Mail Server,跟她溝通然後將訊息傳送給她才算完成,這訊息會待在第二台Mail Server上,直到收件者讀取該訊息,將訊息下載到收件者的電腦後刪除,整個流程大概是這樣。

現在假設一個情境,有一個使用者A為adalf0722@yahoo.com.tw,使用者B為shaq.adalf@gmail.com,A想寄信給B,A利用遠端有台SMTP Services當作mail server發信,當B收到信後,完整mail header如下(其中電腦名稱,IP,網域名稱為杜撰的,其他都是真的):

Received: from sample.test.com (192.168.1.2) by
smtp.mail.com (192.168.1.3) with Microsoft SMTP Server id
8.1.375.2; Thu, 31 Dec 2009 11:02:37 +0800

Received: from tst33 ([192.168.1.1]) by sample.test.com with Microsoft
SMTPSVC(5.0.2195.6713); Thu, 31 Dec 2009 11:02:35 +0800
From: "adalf0722@yahoo.com.tw"
To: "shaq.adalf@mail.com"
Content-Class: urn:content-classes:message
Date: Thu, 31 Dec 2009 11:02:32 +0800
Subject: Send the message using the network

Thread-Topic: Send the message using the network
Thread-Index: AcqJxbIiyzk4CLcJSOa1mph6h4PKgg==
Message-ID: <000001ca89c5$b23830b0$2b02b00a@mail.com>
Accept-Language: zh-TW
Content-Language: zh-TW
X-MS-Exchange-Organization-AuthAs: Anonymous
X-MS-Exchange-Organization-AuthSource: HCS02.mail.com
X-MS-Has-Attach:
X-MS-Exchange-Organization-SCL: 0
X-MS-TNEF-Correlator:
x-originalarrivaltime: 31 Dec 2009 03:02:35.0458 (UTC)
FILETIME=[B3FA7A20:01CA89C5]
Content-Type: text/plain; charset="big5"
Content-Transfer-Encoding: base64
MIME-Version: 1.0

一般讀Email Headers,我覺得最重要的是要看Received Header了,Received Header可以說是郵件傳送的歷程,Received Header是由下往上讀的,由處理到的mail server將資訊加入,最下面的Received是最先處理到的mail server所加的,最上面的則是最後的,最上面的通常也代表了你最後是從哪裡將此郵件讀取並下載下來

以下是我抓出幾行比較需要了解的解釋一下

From: adalf0722@yahoo.com.tw這封郵件是由adalf0722@yahoo.com.tw 寄出的
To: shaq.adalf@mail.com
收件者為shaq.adalf@mail.comContent-Class: urn:content-classes:messageDate: Thu, 31 Dec 2009 11:02:32 +0800
這訊息是在Thu, 31 Dec 2009 11:02:32 +0800 建立的
Subject: Send the message using the network

Received: from tst33 ([192.168.1.1]) by sample.test.com with Microsoft
SMTPSVC(5.0.2195.6713); Thu, 31 Dec 2009 11:02:35 +0800
這封郵件是從tst33送到sample.test.com,發生的時間點為31 Dec 2009 11:02:35 +0800,發信的機器稱它自己為tst33(A的電腦),它的真實IP為192.168.1.1,sample的mail server是使用微軟的smtp services,版本為5.0.2195.6713,注意from後面的tst33,這是機器說它自己叫tst33的,也就是它是可以欺騙mail server的,但是後面帶的ip是它真實的ip,如果去比對的話,就可以發現它有沒有欺騙囉,現在的mail程式有的可以做reverse DNS,很容易就發現此信是不是偽造的

Received: from sample.test.com (192.168.1.2) by
smtp.mail.com (192.168.1.3) with Microsoft SMTP Server id
8.1.375.2; Thu, 31 Dec 2009 11:02:37 +0800

第二個Received是說這封郵件是從sample.test.com送過來的(剛從smtp services寄出),它自己說它叫sample.test.com,它的真實IP為192.168.1.2,由叫smtp.mail.com的機器收下來,它的真實IP為192.168.1.3,收件的是微軟的exchange server,exchange的版本為8.1.375.2,傳輸時間為Thu, 31 Dec 2009 11:02:37 +0800 

各位如果有去注意平常郵件的Email Headers的話,通常會發現到至少有兩個以上Received Header,一個是寄件server加的,一個是收件server加的,如果有多很多的,代表中間可能經過很多台遞送,每經過一台,幾乎就會多一個Received Header囉,有種情況會只看到一個Received Header,那就是內部郵件的遞送,比如說同一個公司內員工郵件傳遞,因為收件與寄件server都是同一台,所以只會有一筆紀錄囉

========================================================================

A typical email header displays several lines that begin with "Received." Note the last "Received" line; this line will look something like this:
Received from genericwebsite.org (123.456.789.101)
If the "Received from" information does not match the email address of the sender or the company being represented in the email, it usually means that the message did not truly come from that individual or company.
And for reverse DNS trace, you can use this link.

========================================================================

How to check Gmail header:
  1. Gmail
    • Open the message in your Gmail inbox.
    • Click the down-arrow in the top-right corner of the message.
    • Click the "Show original" link toward the bottom of the options box. The message will open in a separate window with the full message headers at the top.

Monday, 10 November 2014

maven pom.xml

pom.xml是maven项目的核心,里边定义了项目的基本信息,描述项目如何构建,声明项目的依赖。在编写测试代码的时候,我们可能只会用到声明依赖,其他关于项目个构建的部分,开发会来编写,但我们也可以了解下。下面就介绍下pom.xml中各个元素的含义
1. 第一行是XML的开头,标示了XML文档的版本以及编码方式 <?xml version="1.0" encoding="UTF-8"?>
2. 第二行是project元素,元素里会声明写命名空间以及xsd元素。之后需要添加的项目构建方式、依赖等元素都是project元素的子元素。就是说添加的项目构建方式、依赖等元素需要在<project></project>里边添加。
<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">
3. 元素modelVersion,元素中定义了POM模型的版本,目前对于Maven2、Maven3来说,POM模型的版本只能是4.0.0 <modelVersion>4.0.0</modelVersion>
4. 加入parent元素,可以继承父POM文件,子POM可以重写父POM文件中的元素
<parent>
        <groupId>XX</groupId>
       <artifactId>XX</artifactId>
       <version>1.0.0.SNAPSHOT</version>
</parent>
5. 通过 groupId 、artifactId、version 这三个元素定义了该项目的基本信息 groupId 中的是项目组的名字;artifactId是在maven项目组中的唯一ID,不能有重名的;version是当前的版本,版本号中有SNAPSHOT表示当前的版本是不稳定的版本。
6. build元素中的内容是项目构建时用到的,测试中可能不需要去关注这部分内容
7. 接下来是dependencies 元素,之后用到的所有依赖都包含在这个元素内。每一个依赖在使用dependency元素
<dependencies>
           <dependency>
                    <groupId>com.alibaba.citrus</groupId>
                    <artifactId>citrus-webx-all-in-one</artifactId>
            </dependency>
           <dependency>
                    <groupId>XX</groupId>
                    <artifactId>XX</artifactId>
                    <version>1.0.2</version>
                   <scope>test</scope>
            </dependency>
</dependencies>

dependency元素中的scop 表示的时依赖作用的范围。test表示这个依赖只对测试代码有效。如果不添加scope,则默认是compile,即对主干代码、测试代码都起作用。还可以有其他值,又兴趣可以google下。

Maven dependency scope

Dependency Scope

Dependency scope is used to limit the transitivity of a dependency, and also to affect the classpath used for various build tasks.
There are 6 scopes available:
  • compile
    This is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.
  • provided
    This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.
  • runtime
    This scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath.
  • test
    This scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases.
  • system
    This scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository.
  • import (only available in Maven 2.0.9 or later)
    This scope is only used on a dependency of type pom in the <dependencyManagement> section. It indicates that the specified POM should be replaced with the dependencies in that POM's<dependencyManagement> section. Since they are replaced, dependencies with a scope of import do not actuall

Total visitors since Jan 2012

World Visitor Map