Friday, January 4, 2013

Jumping the Hoops from Canada to Germany

In March of 2012, I moved from Vancouver, Canada to Essen, Germany to live with my pregnant girlfriend. Here is a recount of all the "fun".

1. Youth Mobility Visa

After consolidating all of my assets (furniture, car, stocks), I needed to have some sort of way of staying in Germany for more than 3 months (Tourist visa) and also being able to work. The easiest way was that of the Youth Mobility Visa which allows a young person to live and work in Germany for 1 year or more if you reapply for the same visa under a different option. (http://www.canada.diplo.de/Vertretung/kanada/en/02/visa/yma.html). 

After making an appointment with the German consulate in Vancouver, I gathered the requirements. The requirements say you have to bring a whole lot of planning paperwork and reasons why you want to go to Germany. However, at the consulate in Vancouver, they only asked for proof of health insurance, my passport, a passport photo, and the 4 signed documents detailing my want of the visa (application form, Visa 1, Visa 2, and Personal liability insurance form). The nice lady at the consulate took the subset of my items, looked them over and said to come back in 2 days to get my passport back the visa. I was super surprised but happy - I didn't think it would be that easy!

2.  Access to my Canadian Resources while Abroad

I used to bank with TD Canada Trust however when I learned I was going to be making the big move to Germany, I needed to have some easy way to access my money from abroad. The easiest way I found was to be with a bank that had an international partnership with a German bank. This partnership was found between ScotiaBank and Deutsche Bank in a Global ATM Alliance  (http://www.scotiabank.com/ca/en/0,,316,00.html).

And so, I subsequently created an account at ScotiaBank, moved over my savings, and then closed my TD Canada Trust account. After such, I brought my already purchased airlines ticket and visa to Germany to ScotiaBank and asked them to label my account as a Non-Residence account for tax-purposes. They subsequently did so, and I was a step closer to the big time!

3.  Flight and Deutsche Bank

March came really fast and I had boarded the British Airways flight to London-Heathrow to be connected with a quick flight direct to Düsseldorf. The flight really wasn't too bad - I watched 4 movies and slept the rest. The food was a bit wanting though - my stomach still quivers at the though of soggy British Airway sandwiches.

Anyway, I wanted to have some way to save any money I made in Germany so I decided I wanted to open up a bank account with Deutsche Bank. Lisa and I made an appointment and I when to the main branch in downtown Essen. Everything was straight forward and I had an account opened pretty quickly. They really only needed my passport. Note: Technically they required an Anmeldung document also but they were super nice and said just to bring it in later to update the information in my account. So now I had my Canadian non-resident account and a newly minted German Deutsche Bank account I could start transferring resources over in to. This also allowed me to go and finally get a cell phone plan for my blackberry as they require a bank account to do so.

4. Anmeldung with the city of Essen

My girlfriend and I went to go and make an appointment with the Ausländerbehorde (Foreigner's office) in Essen to get my Anmeldung (registration with the city) out of the way. Unfortunately they were super backed up at the time so I wasn't able to get an appointment until May. I thought I should be worried about this at the time like maybe I was walking around illegally without it. However everyone assured me that this was normal and all will be well (Wird schon!). So May finally came and I went to get and get my registration. It was super quick and easy as it just required me stating where my address was going to be. I got the important piece of paper and then subsequently made my way to my new home with Lisa. Note: It is just a piece of paper that is needed for future use...so protect it or go through the annoyance of getting a new one when you really need it to apply for something.

(http://www.essen.de/de/Rathaus/Aemter/Ordner_33/auslnderbehrdeeinbrgerungsbehrde.html)

5. Job Hunt

Against popular opinion, getting a job in Germany isn't so easy. It all comes down to what "Germany" is considered. I have 2 diplomas (Network Administration and application development) and a Bachelor of Technology (mobile application development)from BCIT in Burnaby, Canada. Most in that area would consider it a very good education. If I was to start looking for jobs in more international locations (like Stuttgart, Berlin, or München), I might have had more luck. However, I was looking for an IT/development in Essen..a not-so-international city. I has a lot of head offices but mostly for energy-based companies and retail companies. I applied everywhere I could with a Lebenslauf in English but details I was going to intensively learn German on the side. I thought that with my programming experience (and since most technology documentation and design is in English), I would be able to find a job without a big hassle. I was wrong. I did not receive any word back at all - not even a rejection. I waited months without a reply. I had learned the first big lesson of moving to Germany - it is a land of Germans who speak German. Therefore, if I ever wanted to get a job in that area, I could only do it in 3 different ways: Learn German very fast, become an expert in my field with experience, or know someone. Since the first 2 methods would take quite a bit of time, I decided to try and network my way in.

Through the website, ToytownGermany, I got in contact with various other expats who gave their advise or criticism openly. Through one of these new friends, I was put into contact with various Expat Facebook groups of which I could make myself know. Most of the groups were based in Düsseldorf so that was the battlefield I had to introduce myself. After making the rounds, I finally asked the big question: "Anyone know of any jobs or companies willing to higher a native english-speaking programmer?" Surprisingly enough, I got some replies right away - and one of them was from a fellow Canadian who was working for a company in Neuss (just across the Rhein from Düsseldorf). As I hadn't had any other replies from other companies, I quickly got in contact with the company and was asked for an interview. 

I was extremely nervous for the interview as it would be my first. On a hot day in the summer, I made a good impression for those at the company. They found out first hand that my Deutsch was not good enough but since their English was of high calibre, that was acceptable. They deemed my programming skills adequate, design methodology okay, and my personality..very Canadian :) I was asked if I wanted a job.

So with amazement, I left the company with a job offer and hope for the future! Funny how networking works sometimes.

6. Health Insurance

It is required by law that everyone has health insurance and since I now had a job, it was time to throw my travel insurance to the side and get some real German health insurance! I chose the public insurance, Techniker Krankenkasse and with Lisa's help, able to get on board. Without Lisa to translate for me, I can imagine foreigner's could have an almost impossible time integrating into German society. If any tip could help a wanna-be english-speaking expat, it is that they should learn German before coming...I mean really learn it as without it, things get messy (especially in non-international city or rural areas).

7. Fatherhood

Since my girlfriend and I were not married, the time had come to state to the German government that I was the father. This required an appointment to be set up at the Jugendamt in Essen. The biggest annoyance is that all of the amt's in Essen are sprawled all over the city and sometimes they aren't advertised very well. So we ended up going to the wrong "Jugendamt" building an had to walk 7 blocks to get to the correct one. Then we had to wait in a waiting room queue for an hour before being allowed to come in. Therein, we were asked to leave because we didn't have a translator and it was required for this meeting. And so, we had to come back 2 days later with my girlfriend's friend who could speak both German and English. After all the paperwork and me fully understanding (and I mean line by painful bloody line) what it means to sign the many documents, I was now officially seen as the father of our unborn child. I was elated  to be seen as the father yet annoyed at the German process. Note again: LEARN GERMAN FIRST as you will save a lot of time and money.

8. Volkshochschule

 I knew I needed to learn German and fast however all the language schools were either super expensive or inflexible in scheduling. Therefore, I learned on my own with PONS books and Rosetta stone until the VHS was starting classes in September. My proficiency was at A2 however the classes filled up far to fast and so I got stuck in A1,1 - the only course with room. And so I began my adventure with the VHS. First impressions: Slow group learning, a little structure-less therefore loud (borderline rude) students talk over others, but overall good for students that care. It filled in a lot of holes in my learning and I would recommend it to anyone! I will be continuing with the next module next semester.

9. Registering for Marriage in Germany

To get marriaged in Germany, you must first make an appointment to register with the Standesamt that you wish to get married. And because I am a foreigner, I have a few extra steps to perform. It was up to me to get from the Canadian government an affidivat that I wasn't already married in Canada. The big problem is that Canada doesn't have that type of document. So during the meeting with the Standesamt, we had to pay for an extra step: our registration had to go to Hamm (High Courts) to be looked at and approved/denied depending on what they find therein. Also I forgot to mention that we also had to hire a certified translator for an hour because a friend would not have sufficed. Funny how much money one has to throw at the government in Germany. Luckily enough 3 weeks after we applied for registration, it was approved from Hamm, and we could have yet another appointment to choose a date. We chose one in December!

10. Passing Probation and Killing Canadian Residency

Six months flew by and I was getting nervous. In Canada, when someone is in probation, they get regular feedback on how they are doing. However, I learned in Germany, that is not the case. The rule of thumb is: If you don't hear anything, you're in the clear. And so at the end of my probation, my worries were put to rest and I transitioned into a full-time employment (conditionally based on a valid visa of course). With a stable job and everything almost in order, I decided to claim non-residency status in Canada because I probably wouldn't be relocating back any time soon. I simply did this by first (cancelled all my credit cards,  double-checking I didn't have any big ties left in Canada), and then filling out the required paperwork. (http://www.cra-arc.gc.ca/E/pbg/tf/nr73/README.html). Took about 2 months, but I received my non-residency reply without incident.

11. Civil Marriage in Germany

The December date came fast and my girlfriend and I were super excited to join in civil matrimony! Of course, I had to again have a certified translator there for everything but it didn't diminish the moment! All of her family was there supporting us and it went off without a hitch! We both said 'Ja' easily and happily. The biggest paperwork was all done during registration and so we just had to sign a few documents this time around and we were in the clear!

12. Family Unification Visa Application

Through direction from my company, they suggested instead of going through them to get a work visa, I should get a Familienzusammenführung Visa. This would probably be easier for me and allow me to get an unlimited one later. I gathered together yet another passport photo, my passport, a pay stub, and Anmeldung. With these, I was able to apply successfully. They gave me a 3-year temporary visa with an option to get an unlimited afterwards. My German at this point is not impressive but I understand quite a bit. Obviously not enough through since they are give me an officially obligation to attend their standardized integration course here (700-800 hours), around 700-800 € overall. Kind of annoying but I will do what I have to do. After this, I should be fluent enough and "integrated" enough to get the unlimited visa which will allow me to stay indefinitely!

13. The New Year and Future

Looking forward, I have a lot, lot, lot of learning to do! Be it through the integration course, VHS classes, or just on my own - I have to sponge in as much as I can as fast as I can as to be able to function well in the society here. Going to be a wild ride ;) But with my wife and son, it is going to be something special!


Wednesday, June 29, 2011

Inconvenient Convenience: Accessing the Outgoing MSMQ Queue in a C# WCF Service Application

To start things off, I had an issue with with a Client/Server application that I was debugging for the company I am working for. It was a project that was twice handed down and had turned into a bit of a "Frankenstein" project.

Anyway, the issue I was attempting to find a solution for was when the the Internet connection would go down and the Client would just keep on locally queuing messages to the remote server. Once the Internet connection came back on, all the messages would be transferred to the server and be processed. To some this might not seem a huge issue however the Internet is provided through a $/MB 3G cellular connection and so efficient data transfer was paramount.

The solution was simply to look if there was a message already queued in the Outgoing MSMQ queue before attempting to queue. It took a bit, but with help from the references below, the implementation looked like:


public int GetQueueLength()
{

string queueFormatName = @"FORMATNAME:DIRECT=TCP:10.10.10.10\private$\queuename";
int outgoingQueueLength = 0;
MessageQueue sourceQueue = new MessageQueue(queueFormatName, QueueAccessMode.ReceiveAndAdmin);

sourceQueue.Formatter = new XmlMessageFormatter(new Type[] {typeof(string)});

outgoingQueueLength = GetMessageCount(sourceQueue);

return outgoingQueueLength;
}

private Message PeekWithoutTimeout(MessageQueue queue, Cursor cursor, PeekAction action)
{
Message result = null;

try
{
result = queue.Peek(new TimeSpan(1), cursor, action);
}
catch (MessageQueueException mqe)
{
Console.WriteLine(mqe.Message);
}

return result;
}

private int GetMessageCount(MessageQueue queue)
{
int count = 0;
Cursor cursor = queue.CreateCursor();

Message message = PeekWithoutTimeout(queue, cursor, PeekAction.Current);

if (message != null)
{
count = 1;
while ((message = PeekWithoutTimeout(queue, cursor, PeekAction.Next)) != null)
{
count++;
}
}

return count;
}



Note 1: 10.10.10.10 would be the address to the remote server. and queuename is the exact queue name specified. For example, another one would be: "FORMATNAME:DIRECT=TCP:172.16.1.1\private$\project1/app2".

project1/app2 would be the queuename in this instance.

Note 2: MSMQ and VPN's don't play nice, see directly below link. I set my MSMQ to be Automatic (Delayed) as to wait for the VPN to come up before starting.

http://mrnye.blogspot.com/2010/02/msmq-over-vpn-connection.html

References:
http://www.yortondotnet.com/2010/04/accessing-outgoing-message-queues-with.html

http://jopinblog.wordpress.com/2008/03/12/counting-messages-in-an-msmq-messagequeue-from-c/

Friday, April 29, 2011

Emailing from a C# application

For an application I am working on I needed to create a .NET web service for emailing out using Gmail's free smtp server. So I created a generic email connector and will input Gmail's server: smtp.gmail.com port: 587 for sending emails.

Friday, July 9, 2010

Ping with style

For long-term testing of a network connection that goes up and down I created a simple little batch file that prints pings with timestamps.

Script:

@ECHO OFF

IF(%1) == () ECHO. && ECHO Proper Use: pingtime.bat [remote host] [output file] [ping count] && GOTO end
IF(%2) == () ECHO. && ECHO Proper Use: pingtime.bat [remote host] [output file] [ping count] && GOTO end
IF(%3) == () ECHO. && ECHO Proper Use: pingtime.bat [remote host] [output file] [ping count] && GOTO end

:start
ECHO ********************************************************************************* >> %2
date /T >> %2
time /t >> %2
ECHO ********************************************************************************* >> %2
ping -n %3 %1>> %2
ECHO.
goto start
:end

Friday, April 30, 2010

OSGi - Eclipse Equinox - How not to faceplant your project

Overview

This setup is based upon 1 feature and 1 plug-in developed in Eclipse for RCP/Plug-in Developers. The plug-in contains a product configuration and two Java classes; HelloWorld.java and Application.java. This document will go step-by-step on what is involved in building/developing a basic RCP feature application for deployment. Note: This process assumes the developer is using the Plug-in Development perspective and using the Package Explorer to view files.


Structure Creation

This is where projects, files, configurations are initially created.


1) Create a Plug-in

a) Right-Click, New -> Project

b) Expand Plug-in Development, Select “Plug-in Project”

c) Give the Plug-in a name such as 'org.vbn.helloworld.plugin'.

d) Make sure in Target Platform, an “OSGi framework: Equinox” is selec

ted and click Next

e) Change version to '1.0.0' and uncheck “Generate an activator, a Java class...” and click Next

f) Uncheck “Create a plug-in using one of the templates” and click Finish

2) Create a Feature

a) Right-Click, New -> Project

b) Expand Plug-in Development, Select “Feature Project”

c) Give the Feature a name such as “org.vbn.hel

loworld.feature” and change version to '1.0.0' and press Next.

d) Make sure that “Initialize from the plug-ins list:” radio is select and choose find and select the previous Plugin name that you just created. Finally, click Finish.

3) Writing the Java Source

a) HelloWorld.java

1. Under your plug-in project and on the /src folder, Right-Click, New -> Class

2. Give your class a package such as 'org.vbn.helloworld'

3. Give your class a name the name HelloWorld.' and then click Finish

4. The test code that I used is:













b) Application.java

1. Under your plug-in project and on the /src folder, Right-Click, New -> Class

2. Give your class a package such as 'org.vbn.helloworld'

3. Give your class a name the name Application.' and then click Finish

4. The test code that I used is:















4) Adding the Product Configuration

a) Right-Click on your plug-in, New -> Product Configuration

b) Give it a file name such as 'Product_Config' and click Finish


Configuration

This is where the dependencies are set and everything is hooked up to work.

1) MANIFEST.MF

a) Double-Click on MANIFEST.MF in /META_INF in your plug-in's project folder

b) Click on the Dependencies Tab and then under “Required Plug-ins”, Click on “Add.”

1. Type in 'org.eclipse.core.runtime,' Select “org.eclipse.core.runtime(3.5.0)” and Click OK

c) Click on the Extensions Tab and under “All Extensions,” Click on “Add.”

1. NOTE: If extensions aren't visible as a Tab, go back to the Overview Tab and click on the Extensions link under “Extension/Extension Point Content.”

2. Either through the filter or just by scrolling down, find “org.eclipse.core.runtime.products” and select it and Click Finish.

3. Click again on “Add” and then either through the filter or just by scrolling down, find “org.eclipse.core.runtime.applications” and select it and Click Finish.

4. Setup the configuration as the following:

i. org.eclipse.core.runtime.applications

1. ID: org.vbn.helloworld.application

2. Name: application

3. Right-Click on (application), New -> Run

4. Click Browse and find the Application class that was created previously. Once found, select OK.

ii. org.eclipse.core.runtime.products

1. ID: org.vbn.helloworld.product

2. Name: product

3. Click on “...(product)”

1. application: org.vbn.helloworld.application

2. name: product

2) feature.xml

a) Double-Click on feature.xml under the feature project folder.

b) Click on the Plug-ins Tab and then under “Plug-Ins and Fragments,” click on “Add.”

c) Type in “org.eclipse.rcp” and Select org.eclipse.rcp(0.0.0) and Click OK

d) Go back into “Add” and type in your plug-in name (ie. org.vbn.helloworld.plugin), Select it and Click OK.

e) Click on the Dependencies Tab and under “Required Features/Plug-Ins ”

1. Check Recompute when feature plug-ins change for any future changes to the plug-ins.

2. Click on “Compute” for it to add the dependency for you. Note: what should be added should be org.eclipse.core.runtime.

3) Product Configuration file (Product_Config.product)

a) Double-Click on the product configuration file under the plug-in project folder.

b) In the Overview Tab, fill in the following information:

1. ID: org.vbn.helloworld.product

2. Version: 1.0.0

3. Name: product

4. Under Product Definition:

i. Product: org.vbn.helloworld.product

ii. Application: org.vbn.helloworld.application

iii. For “The product configuration is based on,” select “features.”

c) Under the Dependencies Tab, Click on “Add” and add “org.vbn.helloworld.feature(1.0.0)”

d) Then afterwards Click again on “Add” and add “org.eclipse.rcp(3.5.1...).”


Aftermath

To Test:

· Go to the Product Configuration file and in Overview, Click on “Launch an Eclipse Application” or ”Launch an Eclipse application in Debug mode”

To Export

· Go to the Product Configuration file and in Overview, Click on “Eclipse Product export wizard.”

Choose the root directory name (such as HelloWorld)

Choose the destination directory

Uncheck “Generate metadata repository”

Click “Finish”


Miscellaneous

· If you want the console to show in the background, add “-console” flag to a shortcut targetting the deployed executable.